- Basic PowerShell Command Structure
- <tt>Get-Command</tt>
- <tt>Get-Help</tt>
- <tt>Get-Member</tt>
- Wrapping Up
Get-Help
Our first order of business is to download and/or update your system’s local PowerShell help:
Update-Help -Force
In case you never knew about updatable help, perhaps you should read the “help on help,” as it were:
Get-Help
We don’t have the space here to delve into every part of PowerShell help. To learn more, I suggest that you pick up my book Sams Teach Yourself Windows PowerShell 5 in 24 Hours and read Hour 3, “Mastering the Windows PowerShell Help System.”
The Windows PowerShell help system includes a large list of conceptual help articles. These articles don’t focus on command syntax, but instead describe general PowerShell concepts such as parameters, jobs, functions, and the like. Fetch a list of all the conceptual help, and you’ll take your PowerShell education to a new level:
Get-Help -Name about_*
The previous command works because the PowerShell team helpfully gives all conceptual help files an “about_” prefix.
Often, when I’m in the heat of the moment in my work, I need nothing more than to be reminded quickly of a command’s syntax. To that end, we can inspect only the command examples by passing in the appropriate parameter:
Get-Help Enter-PSSession -Example
If you want to see the entire help article in the console, use -Full:
Get-Help Receive-Job -Full
One of the best tips I can share is the -ShowWindow parameter. If you have two monitors, you’ll love having your PowerShell console open on one monitor and the full help open on a second one:
Get-Help Get-ChildItem -ShowWindow
Once you’ve mastered basic command usage, you’ll often want to see only a command’s parameter list. Here’s a way to get just the parameter names for a representative cmdlet:
Get-Help Get-WmiObject -Parameter * | Select-Object -Property Name
By contrast, you can fetch the details of a known parameter:
Get-Help Get-WmiObject -Parameter ComputerName
You can take a help article “to go” by using Out-File in conjunction with Get-Help to create a text file:
Get-Help about_Workflows | Out-File “C:\workflow-help.txt”
Finally, you can pop open the (presumably) most current help article by using your default web browser and the -Online switch parameter:
Get-Help Get-DSCConfiguration -Online
At this point, you know how to use Get-Command to find relevant PowerShell commands. You also understand how to use Get-Help to learn how to use those commands. We’ll finish up by considering how to use Get-Member to take our PowerShell knowledge to the next level.