PowerShell Get-Command: Syntax, Applications, Examples

PowerShell commands
Spread the love

The PowerShell Get-Command cmdlet (‘command let’) in my opinion is the first PowerShell command you should know – that is if you are new to PowerShell.

What is PowerShell Get-Command?

PowerShell Get-Command lists all available PowerShell Cmdlets, Functions and Modules in your computer. I guess you are already beginning to see how helpful PowerShell Get-Command can be.

This is why I said that the Get-Command is a Cmdlet you need to know. The reason is simple. If you need a Cmdlet but you don’t know the Cmdlet or you cannot remember it, PowerShell Get-Command will help you find it.

How to Use PowerShell Get-Command to Find Cmdlets

Lets say you are scripting and you want to export some output to a csv file. The great thing about PowerShell Cmdlets is that they are like normal English words in the format Verb-Noun. With this in mind you know that the Cmdlets to export to txt file or csv will begin with the word “Export” – the verb part of the Cmdlet you need. This is the power of the Get-Command in PowerShell!

To find Cmdlets that begin with the word “Export”, run the command below:

Get-Command -Verb "export"

Here is the result of the command

Sponsored Content



PowerShell Parameters (Introduction)

Before I talk about the result of the command, let me digress a bit to tell you about PowerShell Parameters. Most, if not all PowerShell Cmdlets have one or two parameters (arguments).

You would have noticed that in the last command, I entered a hyphen “-” followed by the word “Verb” before I entered “Export”. The word “Verb” is a parameter of the Get-Command Cmdlet. A Cmdlet parameter allows you to filter the results produced by the Cmdlet. Adding “-Verb” parameter allowed me to inform Get-Command that I want only Cmdlets with Verb “Export”.

With that said, lets go back to the Get-Command in PowerShell.

Going back to the results of the last command, notice that “Export-Csv” appears in the list – I highlighted this in the image to make it easy to spot. We have used the Get-Command in PowerShell to find the Cmdlet we require! Isn’t that great!

Exploring More Ways to Use the PowerShell Get-Command Cmdlet

Another way you can use the PowerShell Get-Command Cmdlet is to use the parameter “-ParameterName” to find all Cmdlets that has a particular parameter. Wondering where this might be applicable? Lets see.

Say you are scripting and you want to find all Cmdlets that have a particular parameter, say “NoTyPeInformation“, you can run the command below to get all Cmdlets with this parameter.

Get-Command -ParameterName "NoTyPeInformation"

Here is the result of the command:

Get-Command -ParameterName "NoTyPeInformation"

That is the result of all Cmdlets currently available on my computer.

Sponsored Content


Conclusion

I hope you now know how to use the PowerShell Get-Command Cmdlet. If you have any questions or comments use the “Leave a Reply” form at the end of this guide. Alternatively, you could share your experience with other readers.

Other Helpful Guides


Additional Resources and References

  1. Parameters
  2. Powershell NoTypeInformation: Applications and Examples
  3. PowerShell ForEach loop: Applications with examples

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *

By using this website you agree to accept our Privacy Policy and Terms & Conditions