Posey's Tips & Tricks
How To Get More Help with PowerShell Cmdlets
PowerShell has a reputation for being complicated, and for good reason. Luckily, there is a lot of help available -- if you know where to look for it.
PowerShell is one of those things that I use every single day. But even though PowerShell has been around for more than a decade and I use it frequently, I have to confess that I do not have all of the cmdlet syntaxes memorized. I'm not sure that anyone does. After all, there are thousands of cmdlets. Sure, I have the syntaxes memorized for the cmdlets that I use all the time, but there are plenty of less commonly used cmdlets that I find myself needing a bit of help with.
As such, I thought that it might be fun to share with you some of the tricks that I use when I need a bit of help with a PowerShell cmdlet.
It all starts with knowing which cmdlet to use. If I don't even know where to begin, then I usually end up going online and searching on a phrase such as, "How do I do <something> in PowerShell," with <something> being the thing that I am trying to figure out how to do.
Sometimes however, resorting to a random Web search might not be necessary. One of the really cool things about the Get-Help cmdlet that I have never heard anyone mention is that it can be used to provide general help, if you have at least some idea of what it is that you are trying to do. There are several different commands that you can use in these types of situations.
Let's say, for example, that you need a little bit of extra help understanding how PowerShell modules work. Here are a few cmdlets that you might try:
- Get-Help Modules
- Get-Help About_Modules
- Get-Command *-Module
That last command displays all of the cmdlets that use the word Module as a noun. With the list of cmdlets in hand, you can use the Get-Help cmdlet to start drilling into the individual cmdlets.
If, on the other hand, I know which cmdlet I need to use, then I turn to PowerShell for help. I usually start out by combining the cmdlet with Get-Help. For example, if I needed help with the Get-Process cmdlet, I might type Get-Help Get-Process. This causes PowerShell to display the command's basic syntax and any aliases for the cmdlet that may exist. You can see an example in Figure 1. Incidentally, you can append the -? parameter to the cmdlet that you need help with to get the same result.
OK, that's great and all, but PowerShell's built-in help can sometimes be less than helpful. I can't think of a specific example off the top of my head, but on occasion, I have seen Get-Help display information that would only be helpful if I already knew the basics of working with the cmdlet that I am trying to get help with. So what can you do in those situations?
There are actually a couple of things that come to mind. One thing that you can do is to try to update the help files. Just as Microsoft provides updates to the Windows operating system, it also occasionally updates PowerShell's help files. You can see if any updates are available by typing Update-Help.
My experience has been that updating PowerShell help and then using Get-Help again only works on the rarest of occasions. A better thing to do is to go online for help. Microsoft maintains a Web page for each PowerShell cmdlet. Although these pages may not contain any more information than what the Get-Help cmdlet is already showing you, the online help sometimes provides examples that Get-Help does not show you. The online help for the Get-Process cmdlet, for example, provides 10 examples of how to use the cmdlet, while PowerShell's built-in help does not provide any.
You can access the online help by entering the cmdlet name into your search engine of choice, but you can also do it without having to leave PowerShell. To do so, just append -Online to the Get-Help cmdlet. If, for example, I needed help with the Get-Process cmdlet, I might type Get-Help Get-Process -Online. You can see what this looks like in Figure 2.
PowerShell has a reputation for being complicated, and for good reason. Luckily, there is a lot of help available. You just have to know where to look for that help.
Brien Posey is a 20-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.