Powershell

How to Use the “Get-Command” Command in PowerShell

The cmdlet “Get-Command” in PowerShell retrieves the commands available on Windows. More specifically, it can be used to get commands from PowerShell modules imported from other sessions. However, in order to get the commands from the current session simply place the parameter “-ListImported” along with the “Get-Command” cmdlet.

In this write-up, the “Get-Command ” cmdlet will be discussed in detail.

How to Use the PowerShell “Get-Command” Command?

Using the “Get-Command” cmdlet without parameters will get all the aliases, functions, and cmdlets on the computer.

To get a better understanding of the concept overview the given examples.

Example 1: Use the “Get-Command” Cmdlet to Get the List of Commands

To get the list of all the commands, simply execute the given command:

Get-Command

 

Example 2: Use the “Get-Command” Cmdlet to Get the Current Session’s Commands

To retrieve the current session’s commands simply place the parameter “-ListImported” along with the “Get-Command” cmdlet:

Get-Command -ListImported

 

Example 3: Use the “Get-Command” Cmdlet to Get Information About a Cmdlet

If you want to get the details about a specific cmdlet, then use the “Get-Command” cmdlet along with the desired command. For instance, we have added the “Write-Verbose”:

Get-Command Write-Verbose

 

Example 4: Use the “Get-Command” Cmdlet to Get all Commands of all Types

In PowerShell, users can get all types of commands by placing the “*” wildcard along with the “Get-Command” cmdlet:

Get-Command *

 

Example 5: Use the “Get-Command” Cmdlet to Get an Alias

To get an alias of the particular cmdlet, specify the “Get-Command” cmdlet along with the “-Name” parameter and assign the desired parameter to get its alias:

Get-Command -Name ls

 

That’s all! We have compiled the usage of the “Get-Command” command in PowerShell.

Conclusion

The cmdlet “Get-Command” in PowerShell gets the list of aliases, functions, and commands available on the computer. Moreover, it can import modules and commands from other sessions. This write-up has briefly explained the usage of the “Get-Command” command in PowerShell.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.