understanding the get-help syntax

Hi,

I was studying on how to learn how to find and get powershell cmdlets.   However, when following the advice from an article:

http://www.windowsnetworking.com/articles-tutorials/windows-server-2012/powershell-essentials-part3.html

=====================================================

"

I will be the first to admit that the information that is displayed as a result of using the Get-Help cmdlet can be a
little bit overwhelming. However, things really arent as difficult as they might at first appear. The trick is to know
how to read the syntax information. To show you what I mean, lets take a look at the last block of text in the
screen capture above.
The text starts out with Get-PhysicalDisk. Obviously this is the cmdlet that we are using. From there, you will notice
the following text:

[-Usage <usage[]>

Anything that appears in brackets [] references an optional parameter. In this case, we have a bracket [ followed
by Usage. This indicates that Usage is an optional parameter.

The next thing that we see after Usage is <usage[]> this indicates that the Usage parameter requires some

additional information. You cant just use the command Get-PhysicalDisk Usage because even though Usage is
a valid parameter, PowerShell needs more information. It needs to know what kind of usage you are interested in.
Any time you see a word in between the less than < and greater than > signs, it indicates that you are going to
need to provide some additional information to the parameter. So in this case, -Usage is the parameter and
<usage[]> is the additional data.

Of course this raises the question of where we can find this additional data. Well, it is included in the command
syntax. You will notice that the next section of the syntax is:
{Unknown | AutoSelect | ManualSelect | HotSpare | Retired | Journal}

You will notice that the list of words is enclosed in braces {}. These braces indicate that the words within can be
used in conjunction to the optional parameter. To show you what I mean, lets go back to the original example in
which I wanted to find information related to retired physical disks. To get this information, I could use the
following command:

Get-PhysicalDisk Usage Retired

So you can see that I am appending the Usage parameter to the Get-PhysicalDisk cmdlet, and then I am telling
PowerShell what type of Usage I am interested in.

The syntax that is displayed within the above figure continues on, but the basic pattern repeats. The syntax
information lists a number of optional parameters and the data that can be used with those parameters. Some of
the other optional parameters for instance are Description, -Manufacturer, -Model, -CanPool, and HealthStatus,
and the list goes on.


"

=====================================================

I like to follow along so I got it that []= optional , <>=mandatory, {}= list of items

However, I ran the command and got something different:

--------------

PS C:\Users\Administrator.BWCAT> get-help Get-PhysicalDisk

NAME
    Get-PhysicalDisk

SYNOPSIS
    Gets a list of all PhysicalDisk objects visible across any available Storage Management Providers, or optionally a
    filtered list.


SYNTAX
    Get-PhysicalDisk [-AsJob] [-CanPool <Boolean[]>] [-CimSession <CimSession[]>] [-Description <String[]>]
    [-HealthStatus <HealthStatus[]>] [-Manufacturer <String[]>] [-Model <String[]>] [-ThrottleLimit <Int32>]
    [-UniqueId <String[]>] [-Usage <Usage[]>] [<CommonParameters>]

    Get-PhysicalDisk [-AsJob] [-CanPool <Boolean[]>] [-CimSession <CimSession[]>] [-Description <String[]>]
    [-HealthStatus <HealthStatus[]>] [-Manufacturer <String[]>] [-Model <String[]>] [-StoragePool <CimInstance>]
    [-ThrottleLimit <Int32>] [-Usage <Usage[]>] [<CommonParameters>]

    Get-PhysicalDisk [-AsJob] [-CanPool <Boolean[]>] [-CimSession <CimSession[]>] [-Description <String[]>]
    [-HealthStatus <HealthStatus[]>] [-Manufacturer <String[]>] [-Model <String[]>] [-StorageNode <CimInstance>]
    [-ThrottleLimit <Int32>] [-Usage <Usage[]>] [<CommonParameters>]

    Get-PhysicalDisk [-AsJob] [-CanPool <Boolean[]>] [-CimSession <CimSession[]>] [-Description <String[]>]
    [-HasAllocations <Boolean>] [-HealthStatus <HealthStatus[]>] [-Manufacturer <String[]>] [-Model <String[]>]
    [-SelectedForUse <Boolean>] [-ThrottleLimit <Int32>] [-Usage <Usage[]>] [-VirtualDisk <CimInstance>]
    [-VirtualRangeMax <UInt64>] [-VirtualRangeMin <UInt64>] [<CommonParameters>]

    Get-PhysicalDisk [-AsJob] [-CanPool <Boolean[]>] [-CimSession <CimSession[]>] [-Description <String[]>]
    [-HealthStatus <HealthStatus[]>] [-Manufacturer <String[]>] [-Model <String[]>] [-StorageEnclosure <CimInstance>]
    [-ThrottleLimit <Int32>] [-Usage <Usage[]>] [<CommonParameters>]

    Get-PhysicalDisk [-AsJob] [-CanPool <Boolean[]>] [-CimSession <CimSession[]>] [-Description <String[]>]
    [-HealthStatus <HealthStatus[]>] [-Manufacturer <String[]>] [-Model <String[]>] [-StorageSubSystem <CimInstance>]
    [-ThrottleLimit <Int32>] [-Usage <Usage[]>] [<CommonParameters>]

    Get-PhysicalDisk [[-FriendlyName] <String[]>] [-AsJob] [-CanPool <Boolean[]>] [-CimSession <CimSession[]>]
    [-Description <String[]>] [-HealthStatus <HealthStatus[]>] [-Manufacturer <String[]>] [-Model <String[]>]
    [-ThrottleLimit <Int32>] [-Usage <Usage[]>] [<CommonParameters>]

-------------------------------------

I then tried to do what they said:

Get-PhysicalDisk -Description string        ((However you can see that what he says does not seem to apply to the string, and I dont see a list of things to choose from.  So I am confused on how to understand the syntax here can someone help me to understand the syntax?

Thanks,




  • Edited by wilder7bc 15 hours 20 minutes ago
February 18th, 2015 3:11pm

You can also do Get-Help cmdlLet -Full to get a full listing of the help file, which will give you more details on every parameter available.

[-Description <String[]>] to me says that if I am going to use the Description parameter, I need to supply it with a string or an array of strings

Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 3:20pm

First, I didn't read everything you wrote...

Second, the square brackets don't always mean optional. They also indicate that a parameter can take a collection. Consider the -ComputerName parameter of some cmdlets. Some will indicate this, [-ComputerName <String>] and some this, [-ComputerName <String[]>]. Do you see the second set of square brackets in the second example? The first example will take 1 computer name, and the second can take a collection, such as a comma separated list: computer1,computer2, etc.

Here's a great explanation of the Get-Help (help) syntax by Don Jones: http://youtu.be/TrmDhOJJv-Y?list=PL6D474E721138865A

Edit: I just read clayman2's post and his use of the -Full parameter of the Get-Help cmdlet. One of my favorite ways to read help, is by using the -ShowWindow parameter. Using this will open help up the full help in a GUI, such as Get-Help Get-Service -ShowWindow.


February 18th, 2015 3:28pm

It said the following in the -full

-------------------------------------

 -Description <String[]>
     Gets the physical disks that contain the specified description. Enter a description, or use wildcard
     characters to enter a description pattern.

     Required?                    false
     Position?                    named
     Default value
     Accept pipeline input?       false
     Accept wildcard characters?  false

----------------------------------------

When I read that I take it to mean that it wants me to enter the string after -description as a filter in order to tailor my search?  because if I type  Get-physicaldisk -description "*"    or I enter get-physical -description *   that command seems to work and pull up information.  in my case I only have one disk.

=========================================


PS C:\Users\Administrator.BWCAT> Get-PhysicalDisk -HealthStatus healthy

FriendlyName        CanPool             OperationalStatus   HealthStatus        Usage                              Size
------------        -------             -----------------   ------------        -----                              ----
PhysicalDisk0       False               OK                  Healthy             Auto-Select                       40 GB


PS C:\Users\Administrator.BWCAT> Get-PhysicalDisk -Description "*"

FriendlyName        CanPool             OperationalStatus   HealthStatus        Usage                              Size
------------        -------             -----------------   ------------        -----                              ----
PhysicalDisk0       False               OK                  Healthy             Auto-Select                       40 GB


PS C:\Users\Administrator.BWCAT> Get-PhysicalDisk -Description *

FriendlyName        CanPool             OperationalStatus   HealthStatus        Usage                              Size
------------        -------             -----------------   ------------        -----                              ----
PhysicalDisk0       False               OK                  Healthy             Auto-Select                       40 GB


PS C:\Users\Administrator.BWCAT>

=========================================

Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 3:31pm

"Description" is most often blank so it won't work

get-physicaldisk -FriendlyName PhysicalDisk0

OR

get-physicaldisk -FriendlyName PhysicalDisk*

Much of how CmdLets are used depends on a technical background in Windows and the subsystem or devices you are querying.  THer ei s no help file for that.

You can also do:

help help -full

February 18th, 2015 3:32pm

Get-PhysicalDisk -Description * should not work at all, as you can see in the details of the parameter the Accpet Wildcards is false, but the description states it can accept wildcards.

I do not have this cmdlet so I can not test it, but it doesn't look like any parameters are necessary, they are only used to filter the results returned even more.

Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 3:35pm

This works just fine:

get-physicaldisk -description *

Most descriptions are blank so it is not very useful.

The text is correct but, for some reason, the tag is wrong.

February 18th, 2015 3:38pm

Thanks to Clayman2 for the -Full command  that helped out

Thanks to tommy for enlightening me on the <string[]> and explaining that the second brackets was for a collection of items.  Also thanks for the -showwindo parameter as thats kind of neat to be able to move it around.  As far as the Don Jones video I will check that out.  I have all of his CBT Nuggets as I had a subscription of that but just have not had time to go through it yet as I am in middle of studying for my microsoft server 410 exam.  So as soon as I can I will set down and go through the hours and hours of videos by Don and I am sure that will help me out alot as well.

Thanks to Jrv for pointing out that the reason Description is being a pain is because there is not normally anything there, which explains why the wild card works as well.

Everyone shared something that was helpful and its appreciated.   I keep an alert on my forums post so I can come back and review or if something new is added so feel free to update at anytime.

Thanks!
Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 3:46pm

I like this listing:

https://technet.microsoft.com/en-us/library/hh847741.aspx

Take a bit of looking through to find exactly what you're after, but it's pretty comprehensive.

February 18th, 2015 4:16pm

Thanks Mike I will be sure and check those out!
Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 4:22pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics