Basic Windows PowerShell commands

Cmdlet Alias Description
% Alias for ForEach-Object
? Alias for Where-Object
A
Get-Alias gal Return alias names for Cmdlets.
Compress-Archive Create a new archive/zipped file. [PS 5+]
Expand-Archive Extract files from an archive (zipped) file [PS 5+]
B
Begin Function BEGIN block.
Break Exit a program loop.
C
Catch Handle a terminating error within a scriptblock.
Set-Location cd / chdir / sl Set the current working location.
Get-ChildItem dir / ls / gci Get child items (contents of a folder or registry key).
Clear-Host clear / cls Clear the screen.
Clear-Item cli Remove content from a variable or an alias.
Get-Clipboard Get the current Windows clipboard entry.
Set-Clipboard Set the current Windows clipboard entry.
Get-Command gcm Retrieve basic information about a command.
Invoke-Command icm Run command.
Show-Command shcm Create PowerShell commands in a graphical command window.
Restart-Computer Restart the Operating System on a computer.
Stop-Computer Stop (shut down) a computer.
Get-ComputerInfo Get system and Operating System properties.
Add-Content ac Add to the content of the item.
Get-Content cat / type / gc Get content from item (specific location).
Set-Content sc Set content in the item (specific location).
Clear-Content clc Remove content from a file/item.
Continue Exit the current control block.
Test-Connection Ping one or more computers.
ConvertFrom-CSV Convert object properties (in CSV format) into CSV objects.
ConvertTo-CSV Convert objects into CSV variable-length strings.
ConvertTo-Html Convert the input into an HTML table.
Copy-Item copy / cp / cpi Copy an item from a namespace location.
Get-Credential Get a security credential (username/password).
D
Get-Date Get current date and time.
Set-Date Set system time on the host system.
Get-ChildItem Dir / ls / gci Get child items (contents of a folder or registry key).
Clear-Disk Remove all partition information and un-initialize a disk, erasing all data.
Remove-Item Del / erase / rd / rm / rmdir Delete an item.
Compare-Object diff / compare Compare the properties of objects.
Do Loop while a condition is True.
E
Write-Output Echo Write an object to the pipeline.
End Function END block.
Get-WinEvent Get event log data.
Get-ExecutionPolicy Get the execution policy for the shell.
Set-ExecutionPolicy Change the execution policy (user preference).
Export-Csv epcsv Export to Comma Separated Values (spreadsheet).
Exit Exit a script or exit PowerShell.
F
-F operator Format operator.
Unblock-File Unblock files downloaded from the Internet.
Get-FileHash Compute the hash value for a file.
ForEach-Object foreach Loop through each item in the pipeline ( % ).
ForEach Loop through each item in a collection.
ForEach method Loop through each item in a collection.
For Loop through items that match a condition.
Format-List fl Format output as a list of properties, each on a new line.
Format-Table ft Format output as a table.
Format-Wide fw Format output as a table listing one property only.
Export-FormatData Save formatting data from the current session.
Get-FormatData Get the formatting data in the current session.
G
Get-Item gi Get a file/registry object (or any other namespace object).
Get-ChildItem dir / ls / gci Get child items (contents of a folder or registry key).
Group-Object group Group objects that contain the same value.
New-Guid Create a GUID.
H
Get-Help help Open the help file.
Update-Help Download and install the newest help files on your computer.
Add-History Add entries to the session history.
Clear-History clhy Delete entries from the session history.
Get-History history / h / ghy Get a listing of the session history.
Invoke-History r / ihy Invoke a previously executed Cmdlet.
Get-Host Get host information (PowerShell Version and Region).
Clear-Host clear / cls Clear the screen.
Out-Host oh Send output to the host.
Read-Host Read a line of user input from the host console.
Write-Host Write customized output to the host/screen.
I
IF Conditionally perform a command.
Import-Csv ipcsv Take values from a CSV list and send objects down the pipeline.
Write-Information Specify how PowerShell should handle information stream data.
Invoke-Command icm Run commands on local and remote computers.
Invoke-Expression iex Run a PowerShell expression.
Invoke-WebRequest iwr Get content from a web page.
Invoke-RestMethod irm Send an HTTP or HTTPS request to a RESTful web service.
Get-NetIPAddress Get IPAddress configuration
Get-Item gi Get a file object or get a registry (or other namespace) object.
Invoke-Item ii Invoke an executable or open a file (START).
New-Item md / mkdir / ni Create a new item in a namespace.
Remove-Item del / erase / rd / ri / rm/ rmdir Remove an item.
Set-Item si Change the value of an item.
J
Get-Job gjb Get PowerShell background jobs that are running.
K
Stop-Process kill / spps Stop a running process.
L
Get-Location pwd / gl Get and display the current location.
Set-Location cd / chdir / sl Set the current working location.
M
Measure-Object measure Measure the properties of an object.
Get-Member gm Enumerate the properties of an object.
MessageBox Display a message box to the user
Move-Item mv / move / mi Move an item from one location to another.
O
Compare-Object diff / compare Compare the properties of objects.
Group-Object group Group objects that contain the same value.
Select-Object select Select properties of objects.
Sort-Object sort Sort objects by property value.
Where-Object Filter the objects passed along the command pipeline.
Out-File > Send output to a file.
Out-GridView ogv Send output to an interactive table.
Out-Host oh Send output to the host.
Out-Null Send output to null.
Out-Printer lp Send the output to a printer.
Out-String Send objects to the host as strings.
P
Param Script Parameters.
Test-Path Return true if the path exists, otherwise return false.
Pause Pause and display the message "Press Enter to continue..."
Powershell pwsh Launch a PowerShell session/run a script.
Get-PSDrive gdr Get drive information (DriveInfo).
New-PSDrive mount / ndr Create a mapped network drive.
Remove-PSDrive rdr Remove a provider/drive from its location.
R
Get-Random Get a random number.
Read-Host Read a line of input from the host console.
Clear-RecycleBin Clear the RecycleBin.
Remove-Item del / erase / rd / ri / rm / rmdir Remove an item.
Rename-Item ren / rni Change the name of an existing item.
Restart-Computer Restart the Operating System on a computer.
Return Exit the current scope, (function, script, or script block).
Run/Call & Run a command (call operator).
S
Select-Object select Select properties of objects.
Get-Service gsv Get a list of services.
Restart-Service Stop and then restart a service.
Sort-Object sort Sort objects by property value.
Get-SmbShare Retrieve the SMB shares on the computer.
Start-Sleep sleep Suspend shell, script, or runspace activity.
Select-String sls Search through strings or files for patterns.
T
Trap Handle a terminating error.
Try ... Catch Handle a terminating error within a scriptblock.
U
Unblock-File Unblock files downloaded from the Internet.
Get-Unique gu Get the unique items in a collection.
Update-Help Download and install help files.
V
Clear-Variable clv Remove the value from a variable.
Get-Variable gv Get a PowerShell variable.
New-Variable nv Create a new variable.
Remove-Variable rv Remove a variable and its value.
Set-Variable set / sv Set a variable and a value.
W
Invoke-WebRequest iwr Get content from a web page.
Where-Object where / ? Filter input from the pipeline.
Where method Filter objects from a collection.
While Loop while a condition is True.
Write-Host Display text on screen.
Write-Output write / echo Write an object to the pipeline (1).
Z
Zipfile Compress or Extract zip files.
#
Comment / Remark.
. Run a command script in the current shell. Source or dot operator.
& Run a command, script or function. Call operator.
% Alias for ForEach-Object.
--% Stop parsing input.
? Alias for Where-Object.
$variable = "value" Define a variable also: ${n!a#me} = "value".
$_ The current pipeline object.
@(...) Force an expression to be evaluated as an array.
` Escape or Continue on the next line.

To scroll this page, press [ a – z ] on the keyboard, also on the detail pages 's' = syntax 'e' = examples, '\' = Search.

PowerShell can also run all the standard CMD commands (external commands), .cmd batch files will run within a CMD.exe shell (so can include internal CMD commands), plus all Resource Kit utilities.

Related

A full A-Z list of PowerShell cmdlets.
Websites, additional Cmdlets, Utilities and Books for PowerShell.


Copyright © 1999-2026 SS64.com
Some rights reserved

AltStyle によって変換されたページ (->オリジナル) /