Using Cmdlets

Updated: August 9, 2012

Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0

A cmdlet is a simple, single-function command-line tool. You use cmdlets just as you would use traditional command-line commands and utilities. Begin by typing the name of the cmdlet at the Windows PowerShell command prompt. Windows PowerShell commands are not case-sensitive, so you can type in any case.

For example, try the Get-Date cmdlet:

PS C:\> Get-Date
Thursday, November 10, 2005 4:43:50 PM

To find the cmdlets (and other types of commands) that are available to you, use the Get-Command cmdlet.

PS C:\> Get-Command
Capability      Name                           ModuleName
----------      ----                           ----------
Cmdlet          Add-AppxProvisionedPackage     Dism
Cmdlet          Add-BitsFile                   BitsTransfer
Cmdlet          Add-Computer                   Microsoft.PowerShell.Managemen
Cmdlet          Add-Content                    Microsoft.PowerShell.Managemen
Cmdlet          Add-EnrollmentPolicyServer     PKI
Cmdlet          Add-History                    Microsoft.PowerShell.Core
Cmdlet          Add-JobTrigger                 PSScheduledJob
Cmdlet          Add-KdsRootKey                 Kds
...

You can also use the Get-Command cmdlet to search for the cmdlets you need. For example, to find cmdlets that manage firewall rules, use a command like the following one. Because cmdlet names are usually singular, not plural, the command searches for cmdlets with names that include "FirewallRule".

Capability      Name                       ModuleName
----------      ----                       ----------
CIM             Copy-NetFirewallRule       NetSecurity
CIM             Disable-NetFirewallRule    NetSecurity
CIM             Enable-NetFirewallRule     NetSecurity
CIM             Get-NetFirewallRule        NetSecurity
CIM             New-NetFirewallRule        NetSecurity
CIM             Remove-NetFirewallRule     NetSecurity
CIM             Rename-NetFirewallRule     NetSecurity
CIM             Set-NetFirewallRule        NetSecurity
CIM             Show-NetFirewallRule       NetSecurity

The Get-Command cmdlet also gets commands other than cmdlets, including aliases (command nicknames), functions, scripts, CIM commands, workflows, and executable files that are available in Windows PowerShell.

Try some of the other cmdlets, like Get-Process, Get-Service, Get-EventLog, and Get-Alias.

When you feel comfortable with the simple "Get-" cmdlets, try Get-WmiObject. This cmdlet enables you to view and change the components of remote computers. For example, the following command gets information about the BIOS on the Server01 remote computer:

Get-Wmi-Object Win32_Bios -ComputerName Server01

If you need help with any cmdlet, type:

Get-Help <cmdlet-name> -Detailed

for example:

Get-Help Get-Alias -Detailed