Prof. Powershell

Command Performance

The Get-Command cmdlet reveals all that you need to know about PowerShell.

A terrific PowerShell feature is its ability to reveal its capabilities to you through help files and cmdlets like Get-Member. There is another cmdlet you'll want to explore that can also reveal a lot about PowerShell, called Get-Command. If you run Get-Command at a PowerShell prompt, by default it will display all of the cmdlets available in your current PowerShell session.

But Get-Command can do much more. It can also display other "executables" like applications and scripts. Try this in your PowerShell session:

PS C:\> Get-command -commandtype application

The command might run for a while, but it will display all non-PowerShell programs including .exe, .dll and .txt files that are in your environment path.

Want to see all the functions currently defined? You can use Get-Command:

PS C:\> Get-command -commandtype function

The other command type you might be interested in is "externalscript":

PS C:\> Get-command -commandtype externalscript

This will list all PowerShell scripts that exist in any directory in your path. But wait...there's more.

You should be familiar with the cmdlets Verb-Noun naming convention. Curious about all the cmdlets that start with the verb "Get"?

PS C:\> get-command -verb get

Or perhaps you want to see all the cmdlets related to processes:

PS C:\> get-command -noun process

Here's a nifty trick to get a list of all the verbs and nouns. Try these commands to see for yourself:

PS C:\> get-command | select verb -unique

PS C:\> get-command | select noun -unique

You should get a list of verbs and a list of nouns.

Finally, try a command like this:

PS C:\> get-command get-process | select *

You should get all the information about Get-Process that Get-Command can tell you. One of the properties you'll notice is PSSnapin. You can use Get-Command to discover what cmdlets belong to a particular snapin. One way you can accomplish this is to use the -pssnapin parameter:

PS C:\> get-command -pssnapin Microsoft.PowerShell.Utility

Or use Get-Command to build a report for all your snapins:

PS C:\> get-command | sort pssnapin | format-table -groupby pssnapin Name

So the next time you're trying to figure out what cmdlets you have or what they can do, take command with Get-Command.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular