A cmdlet (pronounced “command-let”) is a special type of command provided in the Windows PowerShell command line environment. They allow users to put certain enhanced operating system functions into effect. Cmdlets are especially useful when used as part of a script or batch file, but they can also be typed at the command prompt. Their command names take the form of a capitalized verb-and-noun pair conjoined with a dash; for example, “Get-Help”.

The following sections contain a list of useful cmdlets you can use in the Windows PowerShell, and examples of them in action.

Get-Command

The Get-Command cmdlet lists other cmdlets. Typing “Get-Command” with no options lists all available cmdlets (and there are a lot of them). It’s more useful to use Get-Command to search for a cmdlet containing a certain string, using the -name option. For example, to search for the cmdlet “Initialize-Volume”:

  • Get-Command
  • Get-Help
  • New-Item
  • Get-Location
  • Set-Location
  • Other cmdlets

Get-Command -name Initialize-Volume

…or, you can use wildcards to perform a partial match on a cmdlet’s name. For instance, the command:

Get-Command -name Vol

…lists all cmdlets with the letters “Vol” in their name.

Get-Help

The Get-Help cmdlet displays a help message giving you more information about how to properly use a cmdlet. For example, to find more information about the Get-Process cmdlet, run:

New-Item

Get-Help Get-Process

The New-Item command is a convenient way to create a new file or directory on your computer from the command line. You may specify that the item to be created is a file or a directory using the -type option. For instance, to create a new directory called C:\My Folder, you could use the command:

New-Item “c:\My Folder” -type directory

…and to create a file called C:\My Folder\new file.txt, you could use the command:

New-Item “c:\My Folder\new file.txt” -type file

It’s important to put the file or directory name in quotes if it contains spaces, as we have done in these examples.

Get-Location

The Get-Location cmdlet tells you what your current directory is. For instance:

Get-Location

Set-Location

The Set-Location cmdlet changes the working directory to one you specify. For instance, to change the current directory to C:\temp, you could use the command:

Set-Location C:\temp

Other cmdlets

For more information and examples of cmdlets to use in Microsoft PowerShell, Microsoft maintains a PowerShell documentation site. It provides details about PowerShell, including cmdlets and help on how to use the cmdlets in scripts on your system.

Command line, Operating system terms, Windows