PowerShell Cheatsheet - Essential Commands for Windows, Linux, and macOS

PowerShell commands with params - little ref

Page content

Here’s a little cheatsheet: PowerShell main commands with params

For interactive script prompts across platforms, see Pause scripts with Press any key in Bash CMD PowerShell and macOS.

awesome seashell

This awesomely powerfull seashell image is produced by AI model Flux 1 dev.

PowerShell Basic Commands

  • Get-Command: Lists all available commands
  • Get-Help <cmdlet>: Displays help information for a specific cmdlet
  • Get-Process: Lists all running processes
  • Get-Service: Lists all services
  • Get-ChildItem (alias: ls, dir): Lists items in the current directory
  • Set-Location (alias: cd): Changes the current directory
  • Clear-Host (alias: cls): Clears the console screen

PowerShell File and Directory Management

  • New-Item (alias: ni): Creates a new file or directory
  • Copy-Item: Copies files and directories
  • Move-Item: Moves files and directories
  • Remove-Item (alias: rm): Deletes files and directories
  • Rename-Item (alias: rnp): Renames a file or directory
  • Get-Content (alias: gc): Displays the content of a file

PowerShell System Administration

  • Start-Process (alias: saps): Starts one or more processes
  • Stop-Process: Stops one or more running processes
  • Start-Service: Starts one or more services
  • Stop-Service: Stops one or more running services
  • Restart-Computer: Restarts the computer
  • Get-WinEvent: Displays Windows event logs
  • Checkpoint-Computer: Sets a restore point on your machine

PowerShell Network Commands

  • Test-Connection: Sends ICMP echo request packets to one or more computers
  • Invoke-WebRequest (alias: curl, wget): Gets content from a web page
  • Get-NetAdapter: Retrieves network adapters
  • Get-NetIPAddress: Gets IP address configuration

PowerShell User and Security Management

  • Get-LocalUser: Lists local user accounts
  • New-LocalUser: Creates a new local user account
  • Set-LocalUser: Modifies a local user account
  • Remove-LocalUser: Deletes a local user account
  • Get-Acl: Gets the security descriptor for a resource

PowerShell Scripting

  • Set-ExecutionPolicy: Sets the PowerShell execution policy
  • Get-Variable: Gets the variables in the current console
  • Set-Variable (alias: set, sv): Sets a variable’s value
  • Remove-Variable (alias: rv): Deletes a variable
  • ForEach-Object: Performs an operation on each item in a specified collection
  • Where-Object: Selects objects with specific properties

PowerShell Job Management

  • Start-Job (alias: sajb): Starts a PowerShell background job
  • Get-Job: Gets PowerShell background jobs running in the current session
  • Receive-Job: Gets the results of background jobs
  • Stop-Job: Stops a PowerShell background job
  • Wait-Job: Waits until one or all of the PowerShell background jobs are complete

PowerShell Output Formatting

  • Format-Table: Formats output as a table
  • Format-List: Formats output as a list
  • Out-File: Sends output to a file
  • Export-Csv: Exports objects to a CSV file
  • ConvertTo-Json: Converts an object to a JSON-formatted string

Use Get-Help <cmdlet> for detailed information on any command, including its parameters and usage examples.

Other Cheatsheets

Subscribe

Get new posts on AI systems, Infrastructure, and AI engineering.