Commonly Used Cmdlets
Table of contents for Intro to PowerShell
- Getting PowerShell
- Basic PowerShell Concepts
- Commonly Used Cmdlets
- PowerShell Scripts and Profiles
- Using PowerShell types with commands and variables
- Error handling in PowerShell scripts
- Calling static methods
- $NestedPromptLevel
- Prompts in PowerShell
The following cmdlets provide functionality that you may find yourself using on a regular basis. It’s also likely that you’ll use some of them without knowing it as you use DOS-based or UNIX-based aliases instead.
Environment Cmdlets
| Cmdlet | Alias/Alternate | Description |
Get-Help |
helpman |
Gets help for a cmdlet or concept. Some useful parameters include -Detailed, -Examples, -Full, -Parameter, and -Verbose. When you request a particular help topic, the content of the topic is displayed. When you use wildcard characters, the topics are displayed as a list. Help about concepts in Windows PowerShell begins with "about_".Also check out the help and man functions. |
Get-Command |
gcm |
Displays basic information about cmdlets, aliases, functions, and executable files. |
Get-Member |
gm |
Displays information about the .NET object that a command returns, including the type, properties, and methods of the object. Use a pipeline operator (|) to send the results of a command to Get-Member. |
Alias Cmdlets
These cmdlets allow getting and setting aliases.
| CmdLet | Alias/Alternate | Description |
Get-Alias |
gal |
Displays aliases defined in the current session. Aliases are also accessible below the Alias: drive. |
Set-Alias |
|
Creates an alias for a cmdlet name, function name, or the name of an executable file. |
Location Cmdlets
These cmdlets allow changing or getting the current location in the PowerShell namespace.
| CmdLet | Alias/Alternate | Description |
Get-Location |
sal |
Gets the current location for operating on objects in the namespace. |
Set-Location |
cd |
Sets the current location for operation on objects in the namespace. Unlike in Windows command prompt windows, this will change the current drive as well as the current directory. |
Push-Location |
pushd |
Pushes the current location onto the stack. |
Pop-Location |
popd |
Changes the current location to the location most recently pushed onto the stack. |
Test-Path |
|
Determines whether all elements of a path exist. |
Drive Cmdlets
These cmdlets operate on PowerShell drives.
| CmdLet | Alias/Alternate | Description |
Get-PSDrive |
gdr |
Gets the currently defined PowerShell drives. |
New-PSDrive |
ndrmount |
Creates a new PowerShell drive. |
Remove-PSDrive |
rdr |
Remove a PowerShell drive. |
Item Cmdlets
These cmdlets operate on items, such as files and directories.
| CmdLet | Alias/Alternate | Description |
Get-Item |
gi |
Gets the item at the specified location. |
New-Item |
ni |
Creates a new item at the specified location. |
Clear-Item |
|
Deletes the contents of an item without deleting the item. |
Set-Item |
si |
Sets the value of the item at the specified location. |
Copy-Item |
copy |
Copies an item. |
Move-Item |
move |
Moves an item. |
Remove-Item |
del |
Removes the item at the specified location. |
Get-ChildItem |
dir |
Gets the items and child items in one ore more specified locations. Specify -recurse to include items in subdirectories. |
Formatting Cmdlets
These cmdlets control how information is formatted in the output stream.
| CmdLet | Alias/Alternate | Description |
Format-List |
fl |
Formats the output as a list of properties in which each property appears on a new line. |
Format-Table |
ft |
Formats the output as a table. |
Format-Wide |
fw |
Formats the output as a wide table that displays only one property of each object. |
Output Cmdlets
These cmdlets control where information is written.
| CmdLet | Alias/Alternate | Description |
Out-Host |
oh |
Sends the output to the command line. |
Out-String |
|
Sends the output to the host as a series of strings. This is the default output cmdlet, so it typically does not need to be specified unless you want to use its parameters to change the display. |
Out-File |
|
Sends the output to a file. |
Out-Printer |
lp |
Sends the output to a printer. |
Out-Null |
|
Deletes output instead of sending it to the console. |
Filtering Cmdlets
These cmdlets filter the output from one cmdlet on its way to the next cmdlet in the pipeline.
| CmdLet | Alias/Alternate | Description |
Sort-Object |
sort |
Sorts objects by property values. |
Where-Object |
where |
Creates a filter that controls which objects will be passed along a command pipeline. |
Write Cmdlets
These cmdlets allow you to write information to the the output stream.
| CmdLet | Alias/Alternate | Description |
Write-Output |
echowrite |
Writes an object to the success pipeline. |
Write-Warning |
|
Writes an object to the warning pipeline. The text is written in yellow on a black background. |
Write-Error |
|
Writes an object to the error pipeline. The text is written in red on a black background. |
Write-Host |
|
Writes an object by using the host user interface. This is a very flexible way to write information to the console. |
Write-Verbose |
|
Writes a string to the verbose display of the host. The $VerbosePreference variable determins whether or not the string is displayed in the console window. Valid values for this variable are SilentlyContinue, Stop, Continue, and Inquire. |
Variable Cmdlets
These cmdlets operate on variables in the Variable: namespace. These variables can be referenced simply by preceding them with $. To reference environment variables, precede them with env:, e.g. $env:windir.
| CmdLet | Alias/Alternate | Description |
New-Variable |
nv |
Creates a new variable. |
Get-Variable |
gv |
Gets the value of a variable. |
Set-Variable |
sv |
Sets the value of a variable. |
Clear-Variable |
cv |
Clears the value of a variable. |
Remove-Variable |
rv |
Deletes a variable. |
You may want to read the Windows PowerShell Getting Started Guide which is installed with PowerShell as it has additional information about how to use several of these cmdlets.



Loading... 
Leave a Reply