How Do I Get-Started With PowerShell?

Commands in PowerShell are called cmdlets (pronounced "command lets") and they are in the form of singular verb-noun commands like Get-Alias (not Get-Aliases).

In my opinion, there are three cmdlets that are the key to figuring out how to use PowerShell and finding help when you need it. These cmdlets are:

  • Get-Help (help)
  • Get-Command (gcm)
  • Get-Member (gm)

Get-Help or Help for short. Help isn't actually an alias, it's a function. I've run help *alias* in the following example:

ps102-1.png

Help doesn't search for cmdlets, it searches for help topics. It can help you find cmdlets, but its power is displaying the help topic for cmdlets. In the following example, help Get-Help displays the help topic for Get-Help:

ps102-21.png

You can use the Detailed, Examples, Full, or Online optional parameters with Get-Help to display additional information or the online version.

One of the lesser known parameters is the Parameter parameter which gives you detailed information about a particular parameter as shown in the following example:

ps102-22.png

The cmdlet that's better for searching for actual cmdlets is Get-Command because it has an option in one of its parameter sets for searching for the CommandType of Cmdlet or cmdlets that use certain verbs and/or nouns. You can't use both the CommandType and Noun or Verb) parameters at the same time because they're in different parameter sets. There's also an option to list the cmdlets added by a module.

ps102-3.png

I specified the Full parameter in the above command even though you can't see all of the results in the image. It contains information about whether or not parameters are required, positional, and what type of input they accept, etc:

ps102-5.png

If I'm looking for a cmdlet so I can find out what aliases exist in PowerShell to keep from having to always type out full cmdlet names. I'm going to use Get-Command to search for all cmdlets about aliases. I'm going to use wildcards on each side of the singular noun alias since I'm unsure of the actual cmdlet name.

ps102-6.png

Now that I have the cmdlet name I want to use Get-Alias, I can get the help topic on it to figure out how to use it:

ps102-7.png

I want to know if there are any aliases for Get-Command. I'm going to use the Definition optional parameter with Get-Alias to return the aliases for Get-Command. I've piped the results of this command to Format-Table and used the Autosize parameter to keep the results as narrow as possible for easier viewing on this blog.

ps102-8.png

I can see that the alias for Get-Command is gcm so I can use that alias instead of typing out the full command. If you're writing a script or providing code to someone else, use the full cmdlet name instead of the alias.

µ