PowerShell Commands
PowerShell cmdlets and scripting reference.
File & Directory Operations
Get-ChildItem -Path C:\List files and directories (ls)
Get-ChildItem -RecurseList files recursively
Copy-Item -Path file.txt -Destination destCopy file
Move-Item -Path file.txt -Destination destMove file
Remove-Item -Path file.txtDelete file
New-Item -Path file.txt -ItemType FileCreate new file
New-Item -Path C:\dir -ItemType DirectoryCreate new directory
Test-Path -Path file.txtCheck if path exists
Get-Content -Path file.txtRead file contents (cat)
Set-Content -Path file.txt -Value "text"Write to file
Process Management
Get-ProcessList all running processes (ps)
Get-Process -Name notepadGet specific process by name
Stop-Process -Name notepadStop process by name
Stop-Process -Id 1234Stop process by ID
Start-Process notepad.exeStart a new process
Get-Process | Sort-Object CPU -DescendingList processes by CPU usage
Get-Process | Where-Object {$_.CPU -gt 100}Filter processes by CPU
Services
Get-ServiceList all services
Get-Service -Name wuauservGet specific service
Start-Service -Name wuauservStart a service
Stop-Service -Name wuauservStop a service
Restart-Service -Name wuauservRestart a service
Set-Service -Name wuauserv -StartupType AutomaticSet service startup type
Get-Service | Where-Object {$_.Status -eq "Running"}List running services
Network Commands
Test-Connection -ComputerName google.comPing a host
Test-NetConnection -ComputerName google.com -Port 443Test TCP connection
Get-NetIPAddressShow IP addresses
Get-NetIPConfigurationShow network configuration (ipconfig)
Get-DnsClientCacheDisplay DNS cache
Clear-DnsClientCacheClear DNS cache (ipconfig /flushdns)
Resolve-DnsName google.comDNS lookup (nslookup)
Get-NetTCPConnectionShow TCP connections (netstat)
System Information
Get-ComputerInfoGet detailed computer information
$PSVersionTableShow PowerShell version
Get-HostGet host information
Get-WmiObject Win32_OperatingSystemGet OS information
Get-WmiObject Win32_ComputerSystemGet computer system info
Get-WmiObject Win32_BIOSGet BIOS information
Get-HotfixList installed Windows updates
Get-EventLog -LogName System -Newest 10Get recent system events
User & Security
Get-LocalUserList local user accounts
Get-LocalGroupList local groups
New-LocalUser -Name "username"Create new local user
Add-LocalGroupMember -Group "Administrators" -Member "user"Add user to group
Get-ExecutionPolicyGet current execution policy
Set-ExecutionPolicy RemoteSignedSet execution policy
Get-Acl -Path C:\file.txtGet file permissions
whoami /userShow current user SID
Variables & Objects
$variable = "value"Assign variable
Get-VariableList all variables
$env:PATHAccess environment variable
[Environment]::SetEnvironmentVariable("VAR", "value", "User")Set environment variable
Get-MemberShow object properties and methods
Get-Process | Get-MemberShow process object members
Measure-ObjectCalculate numeric properties
Select-Object -Property Name, CPUSelect specific properties
Pipeline & Filtering
Get-Process | Where-Object {$_.CPU -gt 50}Filter objects (where)
Get-Service | Sort-Object StatusSort objects
Get-Process | Select-Object -First 5Select first N objects
Get-ChildItem | Measure-Object -Property Length -SumSum file sizes
Get-Process | Export-Csv processes.csvExport to CSV
Import-Csv data.csvImport from CSV
Get-Content file.txt | Select-String "pattern"Search text (grep)
Get-Process | Out-GridViewDisplay in GUI grid view
Remote Management
Enter-PSSession -ComputerName server01Start interactive remote session
Invoke-Command -ComputerName server01 -ScriptBlock {Get-Process}Run command on remote computer
New-PSSession -ComputerName server01Create persistent remote session
Get-PSSessionList active remote sessions
Remove-PSSession -Id 1Close remote session
Enable-PSRemotingEnable PowerShell remoting
Test-WSMan -ComputerName server01Test WinRM connectivity
Registry & Configuration
Get-ItemProperty -Path "HKLM:\Software"Read registry key
Set-ItemProperty -Path "HKLM:\Software" -Name "Key" -Value "Value"Set registry value
New-Item -Path "HKLM:\Software\NewKey"Create registry key
Remove-Item -Path "HKLM:\Software\Key"Delete registry key
Get-PSDriveList PowerShell drives (including registry)
PowerShell 5 to 7 Breaking Changes
# PowerShell 7 uses .NET Core (cross-platform)Major change: PowerShell 7 runs on .NET Core, not .NET Framework
Get-ErrorNEW in PS 7: Enhanced error reporting (replaces $Error[0] | Format-List * -Force)
Get-Help -Name * -ShowWindowREMOVED in PS 7: -ShowWindow parameter no longer available
Add-Type -AssemblyName System.Windows.FormsCHANGED: Some .NET Framework assemblies not available in .NET Core
Get-Command -ParameterName *Credential*IMPROVED: Better parameter searching in PS 7
Select-String -Pattern "test" -UseCultureInvariantNEW in PS 7: Culture invariant matching
Invoke-RestMethod -SkipCertificateCheckNEW in PS 7: Skip SSL certificate validation
ConvertTo-Json -Compress -Depth 100CHANGED: Default depth changed from 2 to 100 in PS 7
Get-Process | Sort-Object -Property CPUCHANGED: Some WMI-based properties not available in PS 7
New-Object -ComObject Excel.ApplicationREMOVED in PS 7 on Linux/macOS: COM objects only on Windows
Get-WmiObject -Class Win32_ProcessDEPRECATED: Use Get-CimInstance instead (works in PS 7)
Get-CimInstance -ClassName Win32_ProcessREPLACEMENT: Use CIM cmdlets instead of WMI (PS 7 compatible)
Invoke-CimMethod -ClassName Win32_Process -MethodName CreateREPLACEMENT: Use CIM instead of Invoke-WmiMethod
Register-CimIndication -Query "SELECT * FROM __InstanceModificationEvent"REPLACEMENT: Use CIM instead of Register-WmiEvent
Get-EventLog -LogName SystemLIMITED in PS 7: Only works on Windows, not cross-platform
Get-WinEvent -FilterHashtable @{LogName="System"}PREFERRED: Use Get-WinEvent instead of Get-EventLog
Start-Transcript -Path transcript.txtCHANGED: Transcript output format improved in PS 7
Set-PSReadLineOption -PredictionSource HistoryNEW in PS 7: Command line prediction (like bash zsh)
Get-Date -AsUTCNEW in PS 7: Convert to UTC timezone
Get-TimeZone -ListAvailableIMPROVED: Better timezone support in PS 7
Test-Connection -Count 4 google.comCHANGED: Default count changed from 4 to 1 in PS 7
Invoke-WebRequest -UseBasicParsingREMOVED in PS 7: -UseBasicParsing no longer needed/available
Format-Table -AutoSize -WrapIMPROVED: Better table formatting in PS 7
Out-Host -PagingCHANGED: Paging behavior improved in PS 7
powershell.exe -Command "script.ps1"CHANGED: Use "pwsh" for PowerShell 7, "powershell" for PS 5
pwsh -Command "script.ps1"NEW: PowerShell 7 executable name (cross-platform)
# $PROFILE paths differCHANGED: PS 7 profile at $PROFILE.CurrentUserCurrentHost differs from PS 5
Get-Module -ListAvailableCHANGED: PS 7 modules in different path than PS 5 modules
Install-Module -Name ModuleName -Scope CurrentUserRECOMMENDED: Use -Scope CurrentUser for PS 7 modules
Import-Module -Name WindowsCompatibilityNEW: Windows Compatibility module for running Windows-only modules
Invoke-Command -WinRSNEW in PS 7: Alternative remoting protocol
Get-ComputerInfo -Property "WindowsProductName"IMPROVED: More properties available in PS 7
[System.Runtime.InteropServices.RuntimeInformation]::OSDescriptionNEW: Get OS info in cross-platform way (PS 7)
Get-Process | Where-Object {$_.Company -like "*Microsoft*"}CHANGED: Some process properties differ in PS 7
dotnet tool install --global PowerShellNEW: Install PS 7 via .NET CLI