Windows Windows 10 Windows Server

13 Get-Command of PowerShell with Example

Example 1: This command will get all the PowerShell Cmdlets, functions, and aliases that are installed on the computer.

Get-Command

Get-Command PowerShell
Get-Command

Example 2: This command will get the commands by type. Like cmdlets, aliases, functions.

Get-command –type cmdlets

Get-Command PowerShell
Get-Command -type Function

Example 3: This command will Count all the Commands.

Get-Command | measure

Get-Command PowerShell
Get-Command Measure

Example 4: This commands will count the commands only by type.

Get-command –type cmdlets | measure

Get-command –type function | measure

Get-command –type aliases | measure

Get-Command PowerShell
measure commands

Example 5: This command will get all commands of all types on the local computer, including executable files in the paths of the Path environment variable.

Get-Command *

 

Get-Command PowerShell
Get-command *

Example 6: This command will show how to use the Get-Command cmdlet with an alias. Although it is typically used on cmdlets and functions, Get-Command also gets scripts, functions, aliases, workflows, and executable files.

Get-Command dir

Get-Command PowerShell
get-command dir

Example 7: This command gets information about the Get-AppLockerPolicy cmdlet. It also imports the AppLocker module, which adds all of the commands in the AppLocker module to the current session.

Get-Command Get-AppLockerPolicy

Get-Command PowerShell
Get-command get-info

Example 8: This command uses the ListImported parameter to get only the commands in the current session.

Get-Command -ListImported

Get-Command PowerShell
get-command -listimport

Example 9: This command gets all of the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and then displays them in noun-based groups. This display can help you find the cmdlets for a task.

Get-Command -Type Cmdlet | Sort-Object -Property Noun | Format-Table -GroupBy Noun

Get-Command PowerShell
get-command format table

Example 10: This command uses the Module parameter to get the commands in the Microsoft.PowerShell.Security and PSScheduledJob modules.

Get-Command -Module Microsoft.PowerShell.Security, PSScheduledJob

Get-Command PowerShell
Get-Command security

Example 11: This command uses the ArgumentList and Syntax parameters to get the syntax of the Get-ChildItem cmdlet when it is used in the Cert: drive. The Cert: drive is a Windows PowerShell drive that the Certificate Provider adds to the session.

Get-Command Get-Childitem -Args Cert: -Syntax

Get-Command PowerShell
Get-Command syntax

Example 12: This command gets cmdlets that have a parameter whose name includes Auth and whose type is AuthenticationMechanism . You can use a command like this one to find cmdlets that let you specify the method that is used to authenticate the user.

Get-Command -ParameterName *Auth* -ParameterType AuthenticationMechanism

Get-Command PowerShell
Get-command auth

Example 13: This command gets the cmdlets and functions that have an output type and the type of objects that they return.

Get-Command -Type Cmdlet | Where-Object OutputType | Format-List -Property Name, OutputType

Get-Command PowerShell
Get-command property

Related posts

Windows Server Backup Step-by-Step Guide for Windows Server 2016

BISMO

How to Restore Your Computer Using System Restore

BISMO

Creating a System Repair Disk in Windows 10

BISMO

Leave a Comment