PowerShell Cheatsheet - PowerShell Command Reference
Essential PowerShell commands for Windows system administration and automation, organized by scenario from file operations to remote management. Copy directly.
Back to SysOpsBasic Commands 5
Get-CommandList all available PowerShell commands (cmdlets, functions, aliases)
Get-Help Get-ProcessView command help, add -Detailed for more info
Get-MemberView properties and methods of pipeline objects
Get-VerbList all PowerShell-approved verbs
Get-AliasList all command aliases
File & Directory 8
Get-ChildItemList directory contents, similar to ls/dir
Set-Location ..Change directory, similar to cd
New-Item -ItemType Directory -Path C:\NewDirCreate new directory or file
Copy-Item src.txt dst.txtCopy file or directory, similar to cp
Move-Item src.txt dst.txtMove or rename file, similar to mv
Remove-Item file.txtDelete file or directory, similar to rm
Rename-Item old.txt new.txtRename file or directory
Test-Path C:\pathCheck if path exists, returns True/False
Content Operations 8
Get-Content file.txtRead file content, similar to cat
Set-Content file.txt "text"Write content to file (overwrite)
Add-Content file.txt "text"Append content to file
Out-File output.txtWrite output to file
Export-Csv data.csv -NoTypeInformationExport objects to CSV file
Import-Csv data.csvImport objects from CSV file
ConvertTo-JsonConvert object to JSON format
ConvertFrom-JsonCreate object from JSON string
Pipeline & Filtering 6
Where-Object { $_.Name -eq "svchost" }Filter objects, similar to grep, can use where alias
Select-Object -First 10 Name,IdSelect object properties or first N items
Sort-Object Name -DescendingSort objects by property
Group-Object StatusGroup objects by property
Measure-Object -Sum -AverageCalculate numeric statistics (sum, average, etc.)
ForEach-Object { $_ * 2 }Perform operation on each pipeline object
Process & Service 9
Get-ProcessList all running processes, similar to ps
Get-Process -Name "chrome"Find process by name
Stop-Process -Name "notepad"Stop a process, similar to kill
Start-Process notepad.exeStart a new process
Get-ServiceList all Windows services
Start-Service SpoolerStart a service
Stop-Service SpoolerStop a service
Restart-Service SpoolerRestart a service
Set-Service Spooler -StartupType AutomaticSet service startup type (Automatic/Manual/Disabled)
Network & Remote 6
Test-Connection 8.8.8.8Test network connectivity, similar to ping
Test-NetConnection google.com -Port 443Advanced network diagnostics, test port connectivity
Invoke-WebRequest -Uri https://api.example.comSend HTTP/HTTPS request, similar to curl
Invoke-RestMethod -Uri https://api.example.comSend REST API request, auto-parses JSON/XML
Enter-PSSession -ComputerName Server01Enter remote PowerShell session, similar to SSH
Invoke-Command -ComputerName Server01 -ScriptBlock { Get-Process }Execute command on remote machine
Scripting 8
$name = "World"Define variable with $ prefix
$array = 1,2,3; $array[0]Array definition and index access
$hash = @{ Name = "Tom"; Age = 30 }Hashtable (dictionary) definition
if ($val -gt 10) { "big" } else { "small" }Conditional, -gt/-lt/-eq for comparison
switch ($val) { 1 { "one" } default { "?" } }Switch multi-branch condition
foreach ($item in $items) { $item }Iterate over array or collection
function Say-Hello { param($name) "Hello $name" }Define function with parameters
try { 1/0 } catch { "error: $_" } finally { "done" }Exception handling try/catch/finally
System Management 8
Get-DateGet current date and time
Set-Date "2026-01-01"Set system date and time
Get-WmiObject Win32_ProcessorQuery system info via WMI (CPU)
Get-CimInstance Win32_LogicalDiskQuery disk info via CIM (recommended over WMI)
Format-Table Name,Id -AutoSizeTable format output with auto-sized columns
Format-List Name,IdList format output, one property per line
Format-Wide Name -Column 4Wide format output, multi-column display
Get-EventLog -LogName System -Newest 10View system event log (latest 10 entries)
💡 Tips
- PowerShell uses Verb-Noun naming convention, e.g. Get-Process, Stop-Service
- Use Get-Command to find available commands, Get-Help for documentation
- Pipeline passes objects not text, use Get-Member to inspect object properties
- Variables use $ prefix, e.g. $var = "hello"
- Use $profile to customize your PowerShell environment, similar to .bashrc