locked
Help with Help RRS feed

  • Question

  • I try to use the help for Powershell, I use the get-command, the get-help and get-member to the extent of what I have learned but it seems to be a hit and miss trying to find a publication devoted to the help available in Powershell. I generally have to give up and search the net for what I am looking for. What I am looking for is a one stop shop for everything help in Powershell. What I would love is a book devoted to the help system in powershell. Where can I find the best source on the help feature for Powershell?

    TexasMitchJ

    Thursday, October 15, 2015 7:20 PM

Answers

  • Sorry but you are asking a very mixed  question.  This is because you need too spend some time learning the basics so you ccan understand what is on eth screen and so you can learn how to control the format and depth of your queries.

    In a nutshell - Get-Member inspects objects.  To learn how to use it type "help get-member -full"

    GM can tell you the properties, methods and events of an object. It cannot tell you what they are for. The product API documentation will give you that.

    For PowerShell internal commands and objects you can use help.  It is extensive and deep.  For add-on commands like SQLServer and Exchange you can also use help.

    Excel and other external programs are not documented by PowerShell.


    \_(ツ)_/

    • Marked as answer by TexasMitchJ Friday, October 16, 2015 3:00 AM
    Friday, October 16, 2015 2:54 AM

All replies

  • The help system is self-documenting.
    PS C:\> help help


    -- Bill Stewart [Bill_Stewart]

    Thursday, October 15, 2015 7:27 PM
  • The help system is self-documenting.
    PS C:\> help help


    -- Bill Stewart [Bill_Stewart]

    TexasMitchJ, be sure to use the advice of the last line of the output of 
      help help
    to run
      get-help Get-Help -online
    and then choose your version of PowerShell using the dropdown near the top of the webpage that is displayed if you are online when you run that command.  That webpage contains the latest help about help and is nicely formatted.

    Also when you follow the instructions in
      help help
    that refers to
      get-help about_*
    use this syntax instead to get more readable output
      get-help about_* | select name,synopsis | ft -wrap -autosize



    • Edited by LarryWeiss Thursday, October 15, 2015 11:58 PM added text
    Thursday, October 15, 2015 10:51 PM
  • Larry, Thank you for the reply. I have been to this site many times in search of how to effectively use the help. Let me add an example of the problem I face. I  use PowerShell to help generate reports in Excel. I am wanting to be able to set the Calculations to manual when I open Excel Object but I am not sur if I need to do this at the Application Layer or the workbook layer. I pipped the objExcel variable to get-member and found either a property or method (I believe it was a method) named sheetCalculate. I wanted to find out more about sheetCalculate but couldn't figure out what command to use to get more information. This seems to be my road block. I getto a certain point and can't figure out how to go further.

    TexasMitchJ

    Friday, October 16, 2015 1:37 AM
  • You are asking a question about Excel that has nothing at all to do with PowerShell.  PowerShell has no direct support for Excel and no Excel CmdLets.

    Your issue is because you doo nothave enough fundamental knowledge of PowerShell, Windows or Excel.  You cannot tell how to understand where the boundaries are.

    For Excel issues you need to use Excel documentation.  You will need to learn Excel VBA or C# and learn how to convert from those languages to PowerShell.

    For more assistance with Excel and the Excel object model please post in the Excel VBA developers forum.

    To clarify. You cannot get "how to" help from PowerShell for foreign subsystems that do not have PowerShell support.  To understand how to know this you need to learn PowerShell at a more fundamental level. THe other thing to do is to search for Excel examples on the Internet.


    \_(ツ)_/

    Friday, October 16, 2015 1:48 AM
  • Thank you for the reply.

    I am not asking a question about excel, I only used it as an example. I get to places in the help file and the definitions run off the screen with ..., I would like to see the full definition and more how to use the property or method and that's where I get stuck. Yes you are right, I do need to learn powershell hence why Im trying to learn the help file. I do understand the boundaries, what I don't understand is why you say there are properties and methods in powershell when there are no use for them.

    So what I think you are saying is the properties and methods I find in powershell help has no meaning and no use? It is just there?

    so when I put in the command ( $objExcel | get-member *calc* )

    and get the following, I can't go any further in discovery and there is no use for this?

       TypeName: Microsoft.Office.Interop.Excel.ApplicationClass

    Name                           MemberType Definition
    ----                           ---------- ----------
    AfterCalculate                 Event      Microsoft.Office.Interop.Excel.AppEvents_AfterCalculateEventHandler AfterC...
    SheetCalculate                 Event      Microsoft.Office.Interop.Excel.AppEvents_SheetCalculateEventHandler SheetC...
    add_AfterCalculate             Method     void add_AfterCalculate(Microsoft.Office.Interop.Excel.AppEvents_AfterCalc...
    add_SheetCalculate             Method     void add_SheetCalculate(Microsoft.Office.Interop.Excel.AppEvents_SheetCalc...
    Calculate                      Method     void Calculate(), void _Application.Calculate()
    CalculateFull                  Method     void CalculateFull(), void _Application.CalculateFull()
    CalculateFullRebuild           Method     void CalculateFullRebuild(), void _Application.CalculateFullRebuild()
    CalculateUntilAsyncQueriesDone Method     void CalculateUntilAsyncQueriesDone(), void _Application.CalculateUntilAsy...
    remove_AfterCalculate          Method     void remove_AfterCalculate(Microsoft.Office.Interop.Excel.AppEvents_AfterC...
    remove_SheetCalculate          Method     void remove_SheetCalculate(Microsoft.Office.Interop.Excel.AppEvents_SheetC...
    CalculateBeforeSave            Property   bool CalculateBeforeSave {get;set;}
    Calculation                    Property   Microsoft.Office.Interop.Excel.XlCalculation Calculation {get;set;}
    CalculationInterruptKey        Property   Microsoft.Office.Interop.Excel.XlCalculationInterruptKey CalculationInterr...
    CalculationState               Property   Microsoft.Office.Interop.Excel.XlCalculationState CalculationState {get;}
    CalculationVersion             Property   int CalculationVersion {get;}
    MultiThreadedCalculation       Property   Microsoft.Office.Interop.Excel.MultiThreadedCalculation MultiThreadedCalcu...
    OnCalculate                    Property   string OnCalculate {get;set;}


    • Edited by TexasMitchJ Friday, October 16, 2015 2:22 AM
    Friday, October 16, 2015 1:59 AM
  • Sorry but you are asking a very mixed  question.  This is because you need too spend some time learning the basics so you ccan understand what is on eth screen and so you can learn how to control the format and depth of your queries.

    In a nutshell - Get-Member inspects objects.  To learn how to use it type "help get-member -full"

    GM can tell you the properties, methods and events of an object. It cannot tell you what they are for. The product API documentation will give you that.

    For PowerShell internal commands and objects you can use help.  It is extensive and deep.  For add-on commands like SQLServer and Exchange you can also use help.

    Excel and other external programs are not documented by PowerShell.


    \_(ツ)_/

    • Marked as answer by TexasMitchJ Friday, October 16, 2015 3:00 AM
    Friday, October 16, 2015 2:54 AM
  • Thank you

    In that nut shell I am now leery to use this forum in the future. I thought that this forum was to ask questions after an extensive search has not provided an answer. I guess I was wrong. Everyone has to start someplace and be chastised for asking a question because the question comes from a non-expert seems out of line. So only experts need to ask questions here, who wait, they are experts they don't ask questions.

    Tell me again what this forum is for.

    Thanks again for answering the question. In the future I will just not know.

    Friday, October 16, 2015 3:11 AM
  • No one is chastising you. You are asking the same kind of questions that many new users ask.  The problem is that there have been at least three good answers and you could not understand them because you have no context in which to understand them in.

    I know you are frustrated.  We cannot give yo a private tutorial.  We can try to point you in a direction where yu can gain more information but the rest is up to you.

    I recommend getting one of the many good books on PowerShell.  It wil get you up t speed faster than trying to ask how all the time.

    The language we use to describe things is complex and technical as well as being product specific.  If you ask a specific question about PowerShell or about how to do a specific thing we can easily answer it.  Your question is too broad and too vague to allow for a clear answer.

    Good luck.  I am sure you will catch up.

    Here is a good place to start.  It has comprehensive training courses and it is free: http://learning.microsoft.com/manager/LearningPlanV2.aspx?resourceId=2bb78a84-c3ce-4aa1-b80e-18590cfd170b&clang=en-US&cats=d4e8e42c-3d5a-4a6e-915d-d99556a49bd7&locale=en-US


    \_(ツ)_/

    Friday, October 16, 2015 3:24 AM
  • Here is a decent write-up n using help effectively: http://www.tomsitpro.com/articles/powershell-get-objects,2-763.html


    \_(ツ)_/

    Friday, October 16, 2015 3:29 AM
  • TexasMitchJ

    One of the problems you mentioned is Get-Member cutting off the Definition on the screen. There are a couple of different ways I like to handle that.  The first is to use Format-List. When format list is used, the Definition will be word wrapped in the output so you can see the full content. That option, however, can quickly become overwhelming if you have a lot of members returned.

    PS C:\> $excel | Get-Member -type method "*calc*" | Format-List
    
    TypeName   : Microsoft.Office.Interop.Excel.ApplicationClass
    Name       : add_AfterCalculate
    MemberType : Method
    Definition : void add_AfterCalculate(Microsoft.Office.Interop.Excel.AppEvents_AfterCalculateEventHandler ), void
                 AppEvents_Event.add_AfterCalculate(Microsoft.Office.Interop.Excel.AppEvents_AfterCalculateEventHandler )
    
    TypeName   : Microsoft.Office.Interop.Excel.ApplicationClass
    Name       : add_SheetCalculate
    MemberType : Method
    Definition : void add_SheetCalculate(Microsoft.Office.Interop.Excel.AppEvents_SheetCalculateEventHandler ), void
                 AppEvents_Event.add_SheetCalculate(Microsoft.Office.Interop.Excel.AppEvents_SheetCalculateEventHandler )
    
    TypeName   : Microsoft.Office.Interop.Excel.ApplicationClass
    Name       : Calculate
    MemberType : Method
    Definition : void Calculate(), void _Application.Calculate()

    The other option I like to use it piping to Out-GridView. It gives a nice window with the full content. I can't show that in this reply but you would so something like this.

    PS C:\> $excel | Get-Member -type method "*calc*" | Out-GridView

    Now both of these will only let you see the full definition where you can see the method or property syntax and all off the overload variances, but to jrv's point that's all PowerShell can give you. Once you get to that point you are looking at something that has been coded in a different system and PowerShell can only show the data that has been made visible to it by those systems.  One of ways this is made easier is that Get-Member shows you the Name and TypeName, which makes a websearch very easy to get more info. The first entry on a websearch for "Microsoft.Office.Interop.Excel.ApplicationClass Calculate" takes me straight to the MSDN page for that method.

    Hope that helps a little and good luck.



    • Edited by SitrucHtims Friday, October 16, 2015 4:00 AM type-os
    Friday, October 16, 2015 3:57 AM
  • Sitruc has a point but it really just adds to the confusion..  The original question is about help.  Get-Member is nit part of the help system even though it is very helpful.

    The output of all commands can be modified in dozens of ways.  Reading a book or taking a course will familiarize you with how PowerShell formats output and how to customize.  It is to big of a subject to cover in a forum. There are dozens of blogs that have posted extensively about this.

    This following will cause the lines too wrap instead of truncate.

    get-process| get-member | format-table -wrap

    This will be oof little use if you do not know what the member list is telling you.  You have to learn what each line and column is telling you about the object.

    Example:

    UserProcessorTime          Property       timespan UserProcessorTime {get;}

    This is a property that is a timespan type and is read-only.  We know this because the display tells us that it only supports the "get" method.  Without a book or training you could never guess this.  If you try and ask for a definition of very one of these new things you will spend the rest of your life asking in forums.  You will get all information in an out-of-context way making it very hard  to use answers effectively.

    The good thing is that PowerShell is very useful even before you understand it well. Any CMD commands you know can still be used.  You can also use any program in the system.  You can list commands and find new commands that can be useful in your work.  While you use PS you will slowly learn how to make it more useful. 


    \_(ツ)_/

    Friday, October 16, 2015 4:16 AM
  • Thanks to all that replied.

    I have two physical books (Windows PowerShell 3.0 by Ed Wilson and Windows PowerShell in Action by Bruce Payette) and a slew of ebooks. This is the first time I have ever posted to a forum, I search until I can find the answer. It turns out that this was multiple issues I was asking about even though I thought in my mind, If I can figure out how to get this information to display correctly I should be able to use it. I guess the books don't mention what you can't do, only what you can do.

    Maybe you can quickly explain one other thing then I will leave this alone. When I am looking at Methods  of the $objExcel | get-member or $workbook | get-member "FOR EXAMPLE" I see methods that I use now such as Activate, add_WorkbookOpen, Close, Save, SaveAs. Quit

    Properties ActiveSheet, Sheets, Worksheets. along with others

    Are the use of these methods and properties that I use now somehow different in their usage from the others that are listed?

    Again, thanks to all that responded.

    Friday, October 16, 2015 4:59 AM
  • . When I am looking at Methods  of the $objExcel | get-member or $workbook | get-member "FOR EXAMPLE" I see methods that I use now such as Activate, add_WorkbookOpen, Close, Save, SaveAs. Quit

    Properties ActiveSheet, Sheets, Worksheets. along with others

    Are the use of these methods and properties that I use now somehow different in their usage from the others that are listed?

    What does that mean? Different from what?  You ask "are they different?" What methods are you comparing them to?

    "Usage" is a loaded term when used here.  Get-Member does not display "usage". It displays the method signature(s) in the definition column. Usage is only available in the documentation for the Excel object model.

    To find documentation you can do this:

    $xl=New-Object -ComObject Excel.Application

    You can paste the 'Excel.Application' at Google  - https://www.google.com/?gws_rd=ssl#newwindow=1&q=Excel.Application

    The first link found is: https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.application.aspx?f=255&MSPPError=-2147217396

    The second one is: https://msdn.microsoft.com/en-us/library/office/ff194565.aspx

    $wb=$xl.Workbooks.Add()
    $wb | gm

    This gives us a method named "AcceptAllChanges()"

    We can then Bing "Excel Workbook.AcceptAllChanges"

    Which gives us this: https://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook.acceptallchanges.aspx

    Of course it is faster and easier if we get a book on Excel and study the object model. 

    The most important thing about good books is the discussion.  Payette's books have some of the best discussions of why, how and where it is useful.  It is very much worth going through and doing every exercise and all quizzes until you fully understand the lesson.  Do not move on until each lesson is clear.  The book builds almost like a good drama. As you progress, slowly at first then faster, you build a clear picture of how PowerShell is built.  Skimming will not let you learn.

    The biggest hill for non-programmers to climb is understanding program control and automation.  I know many admins who studied programming in college that have a hard time with learning Windows programming.  PowerShell can be used in a very simple way.  When you start "newing" COM objects and Net types you are programing.  Without a programming background you will need to learn programming.  In Payette's first book he makes this statement in a number of ways. 

    PS is a wrapper around dotNet for the purpose of exposing a consistent way of interacting with admins and others for the purpose of managing Windows.  It can do many things but its primary mission is managing.  "Windows Management Framework" - WMF.  It is closely coupled with the DMTF standards group.  Using it as a programing environment is not its primary purpose.


    \_(ツ)_/


    • Edited by jrv Friday, October 16, 2015 5:27 AM
    Friday, October 16, 2015 5:26 AM
  • Here is a decent write-up n using help effectively: http://www.tomsitpro.com/articles/powershell-get-objects,2-763.html


    \_(ツ)_/

    In that article it shows one way to get basic help text by this pattern:
      <commandname> -?
    as in
      Get-Process -?
    I had never seen this used before, and don't know where the PowerShell help text resides that describes that pattern.  Apparently
      <commandname> -?
    it is equivalent to
      get-help <commandname>
    Friday, October 16, 2015 1:43 PM
  • Guys

    This discussion has really helped, I learned how much I didn't know and still need to learn. Because of the discussion I have some new insight and having somewhat a better idea of what I should be looking for I found this;

    https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.constants%28v=office.14%29.aspx

    Along with this I needed yet another page

    https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.xlcalculation%28v=office.14%29.aspx

    Now I have been able to construct what I have been looking for - which is to switch Automatic Calculation in Excel to Manual and back to Automatic before exiting.

    $xlCalculationManual = -4135
    $xlCalculationAutomatic = -4105
    $objExcel = New-object -comObject excel.applicatio
    $objWS = $objExcel.workbooks.add()
    $myExcel.Calculation = $xlCalculationManual

    {
    code here
    }

    $myExcel.Calculation = $xlCalculationAutomatic

    Save and quit
    Do process clean up

    I was expecting to find this information in the help file and figured I was not using the help file properly.

    Thanks again to everyone the contributed


    • Edited by TexasMitchJ Friday, October 16, 2015 2:28 PM
    Friday, October 16, 2015 2:16 PM
  • TexasMitchJ, there is also a PowerShell specific TechNet support forum at

    https://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverpowershell
    Friday, October 16, 2015 3:06 PM
  • It turns out to be documented right there in
    Get-Help Get-Help
    I looked right past it.
    Friday, October 16, 2015 11:40 PM