Free developer tool

Free PowerShell Commands Cheat Sheet

A PowerShell commands cheat sheet is a quick reference for the cmdlets you use to work with files, processes, services, networks, JSON and CSV data, scripts, modules and remote machines. Search 100 commands by cmdlet, alias, Bash name or task, see the Bash equivalent, copy a working example and spot the ones that delete data before you run them. Nothing here runs on your machine.

Showing 100 of 100 commands

Help & discovery

Get-Help

Show help for any cmdlet, including working examples.

Syntax: Get-Help <cmdlet> [-Examples | -Detailed | -Full | -Online]

Alias: help, manBash: man ls

-Examples
only the examples
-Online
open the docs page in a browser
-Full
every parameter in detail
PS> Get-Help Get-ChildItem -Examples

Update-Help

Download the latest local help files. Run it once on a new machine so Get-Help shows full content.

Syntax: Update-Help [-Scope CurrentUser] [-Force]

-Scope CurrentUser
no admin rights needed
-Force
download again even if checked today
PS> Update-Help -Scope CurrentUser

Get-Command

Find cmdlets, functions and programs by name, verb or noun, and show where an executable lives.

Syntax: Get-Command [name] [-Verb v] [-Noun n] [-Module m]

Alias: gcmBash: which git

-Noun Service
every command that works on services
-Verb Get
every Get- command
-Module
commands in one module
PS> Get-Command -Noun Service

Get-Member

List the properties and methods of the objects coming down the pipeline. The fastest way to learn what you can select or filter on.

Syntax: <command> | Get-Member [-MemberType Property|Method]

Alias: gm

-MemberType Property
properties only
PS> Get-Process | Get-Member -MemberType Property

Get-Alias

Show aliases, or find the short names for a cmdlet.

Syntax: Get-Alias [name] [-Definition cmdlet]

Alias: galBash: alias

-Definition Get-ChildItem
aliases that point to a cmdlet
PS> Get-Alias -Definition Get-ChildItem

Set-Alias

Create or change an alias. It lasts for this session only unless you add it to your $PROFILE.

Syntax: Set-Alias -Name <alias> -Value <command>

Alias: salBash: alias g='git'

PS> Set-Alias -Name g -Value git

Get-History

List the commands you ran in this session. PSReadLine also keeps a history file across sessions.

Syntax: Get-History [-Count n]

Alias: h, historyBash: history

-Count 20
only the last 20
PS> Get-History -Count 20

$PSVersionTable

Show the PowerShell version and edition: Desktop is Windows PowerShell 5.1, Core is PowerShell 7.

Syntax: $PSVersionTable[.PSVersion]

Bash: bash --version

PS> $PSVersionTable.PSVersion

Get-Verb

List the approved verbs (Get, Set, New, Remove...) that every cmdlet name starts with.

Syntax: Get-Verb [verb]

PS> Get-Verb | Sort-Object Verb

Files & folders

Get-ChildItem

List files and folders in a directory.

Syntax: Get-ChildItem [path] [-Force] [-File | -Directory]

Alias: ls, dir, gciBash: ls -la

-Force
include hidden and system files
-File
files only
-Directory
folders only
PS> Get-ChildItem -Force

Get-ChildItem -Recurse

Find files by name in a folder and every subfolder.

Syntax: Get-ChildItem [path] -Recurse -Filter <pattern>

Alias: dir -s, gci -sBash: find . -name "*.log"

-Filter *.log
match a wildcard pattern (fast)
-Include
several patterns
-Depth 2
limit how deep it goes
PS> Get-ChildItem -Recurse -Filter *.log

Set-Location

Change the current folder. Also moves into other drives such as HKLM: or Env:.

Syntax: Set-Location <path>

Alias: cd, sl, chdirBash: cd ~/projects

-
go back to the previous folder (PowerShell 6+)
PS> Set-Location ~\Projects

Get-Location

Show the current folder.

Syntax: Get-Location

Alias: pwd, glBash: pwd

PS> Get-Location

Push-Location / Pop-Location

Remember the current folder, go somewhere else, then jump back.

Syntax: Push-Location <path> · Pop-Location

Alias: pushd / popdBash: pushd / popd

PS> Push-Location C:\Windows\Temp

New-Item

Create a folder, an empty file, or a file with starting content.

Syntax: New-Item -ItemType Directory|File -Path <path> [-Value text] [-Force]

Alias: ni, mkdirBash: mkdir -p logs · touch notes.txt

-ItemType Directory
create a folder
-ItemType File
create a file
-Value
starting content
-Force
create missing parent folders
PS> New-Item -ItemType Directory -Path logs

Careful: With -ItemType File -Force, an existing file of the same name is replaced by an empty one.

Copy-Item

Copy files or folders.

Syntax: Copy-Item <path> -Destination <path> [-Recurse] [-Force]

Alias: cp, copy, cpiBash: cp -r src backup

-Recurse
copy a folder and everything in it
-Force
also overwrite read-only files
-WhatIf
show what would be copied
PS> Copy-Item .\src -Destination .\backup -Recurse

Careful: Files that already exist at the destination are overwritten without asking.

Move-Item

Move files or folders. Fails if the destination file exists unless you add -Force.

Syntax: Move-Item <path> -Destination <path> [-Force]

Alias: mv, move, miBash: mv report.txt archive/

-Force
replace an existing destination file
PS> Move-Item report.txt .\archive\

Rename-Item

Rename a file or folder in place.

Syntax: Rename-Item <path> -NewName <name>

Alias: ren, rniBash: mv old.txt new.txt

PS> Rename-Item old.txt -NewName new.txt

Remove-Item

Delete files, folders, registry keys or variables.

Syntax: Remove-Item <path> [-Recurse] [-Force] [-WhatIf]

Alias: rm, del, rmdir, riBash: rm -rf build

-Recurse
delete a folder and everything in it
-Force
include hidden and read-only items
-WhatIf
list what would be deleted, delete nothing
PS> Remove-Item .\build -Recurse -WhatIf

Careful: Deleted items skip the Recycle Bin. Remove-Item -Recurse -Force removes whole folders, hidden and read-only files included, with no undo. Run it with -WhatIf first.

Get-Content

Read a file line by line, or follow a log as it grows.

Syntax: Get-Content <path> [-Tail n] [-Wait] [-TotalCount n] [-Raw]

Alias: cat, gc, typeBash: tail -n 50 -f app.log

-Tail 50
only the last 50 lines
-Wait
keep printing new lines
-TotalCount 10
only the first 10 lines
-Raw
the whole file as one string
PS> Get-Content app.log -Tail 50 -Wait

Set-Content

Write text to a file, replacing what was there.

Syntax: Set-Content <path> <value> [-Encoding utf8]

Bash: echo 'hello' > notes.txt

-Encoding utf8
choose the file encoding
PS> Set-Content notes.txt 'hello'

Careful: Replaces the whole file. Use Add-Content to append instead.

Add-Content

Append text to the end of a file, creating it if needed.

Syntax: Add-Content <path> <value>

Bash: echo 'line' >> notes.txt

PS> Add-Content notes.txt 'another line'

Out-File

Save command output to a text file, the same as the > operator.

Syntax: <command> | Out-File <path> [-Append] [-Encoding utf8]

Bash: ps > procs.txt

-Append
add to the end instead of replacing
-Encoding utf8
Windows PowerShell 5.1 writes UTF-16 by default
PS> Get-Process | Out-File procs.txt

Test-Path

Return True or False for whether a file, folder, registry key or variable exists.

Syntax: Test-Path <path> [-PathType Leaf|Container]

Bash: [ -e config.json ]

-PathType Leaf
must be a file
-PathType Container
must be a folder
PS> Test-Path .\config.json

Get-Item

Get one file or folder as an object, with its size, dates and attributes.

Syntax: Get-Item <path>

Alias: giBash: stat app.log

PS> (Get-Item .\app.log).Length

Get-FileHash

Compute a file checksum to check a download.

Syntax: Get-FileHash <path> [-Algorithm SHA256|SHA1|SHA512|MD5]

Bash: sha256sum setup.exe

-Algorithm SHA256
the default
PS> Get-FileHash .\setup.exe -Algorithm SHA256

Compress-Archive

Create a .zip file from files or folders.

Syntax: Compress-Archive -Path <paths> -DestinationPath <zip> [-Update] [-Force]

Bash: zip -r dist.zip dist

-Update
add or refresh files in an existing zip
-Force
replace an existing zip
PS> Compress-Archive -Path .\dist\* -DestinationPath dist.zip

Expand-Archive

Extract a .zip file.

Syntax: Expand-Archive <zip> -DestinationPath <folder> [-Force]

Bash: unzip dist.zip -d dist

-Force
overwrite files that already exist
PS> Expand-Archive dist.zip -DestinationPath .\dist

Invoke-Item

Open a file with its default app, or a folder in File Explorer.

Syntax: Invoke-Item <path>

Alias: iiBash: xdg-open . · open .

PS> Invoke-Item .

Processes & services

Get-Process

List running processes with CPU, memory and IDs.

Syntax: Get-Process [-Name n] [-Id id]

Alias: ps, gpsBash: ps aux --sort=-%cpu | head

-Name chrome
only processes with that name
-Id 1234
one process by ID
PS> Get-Process | Sort-Object CPU -Descending | Select-Object -First 10

Stop-Process

End a process by name or ID.

Syntax: Stop-Process -Name <name> | -Id <id> [-Force]

Alias: kill, sppsBash: pkill notepad · kill -9 1234

-Name
every process with that name
-Id
one process
-Force
no prompt, even for processes you do not own
PS> Stop-Process -Name notepad

Careful: The process ends immediately and unsaved work in it is lost. -Name stops every process with that name, not just one window.

Start-Process

Start a program, optionally as administrator or in a new window.

Syntax: Start-Process <file> [-ArgumentList args] [-Verb RunAs] [-Wait]

Alias: start, sapsBash: sudo -i

-Verb RunAs
run as administrator (UAC prompt)
-Wait
wait until it exits
-ArgumentList
arguments to pass
-NoNewWindow
use the current console
PS> Start-Process pwsh -Verb RunAs

Get-Service

List Windows services and whether they are running.

Syntax: Get-Service [-Name n] [-DisplayName d]

Alias: gsvBash: systemctl list-units --type=service

-Name Spooler
one service
-DisplayName *print*
match the friendly name
PS> Get-Service | Where-Object Status -eq 'Running'

Start-Service

Start a stopped service. Needs an elevated (administrator) session.

Syntax: Start-Service -Name <service>

Alias: sasvBash: sudo systemctl start cups

PS> Start-Service -Name Spooler

Stop-Service

Stop a running service. Needs an elevated session.

Syntax: Stop-Service -Name <service> [-Force]

Alias: spsvBash: sudo systemctl stop cups

-Force
also stop services that depend on it
PS> Stop-Service -Name Spooler

Careful: Apps that rely on the service stop working until it is started again. -Force also stops every dependent service.

Restart-Service

Stop and start a service, for example after a config change. Needs an elevated session.

Syntax: Restart-Service -Name <service> [-Force]

Bash: sudo systemctl restart cups

-Force
restart even if other services depend on it
PS> Restart-Service -Name Spooler

Set-Service

Change how a service starts: Automatic, Manual or Disabled.

Syntax: Set-Service -Name <service> -StartupType Automatic|Manual|Disabled

Bash: sudo systemctl disable cups

-StartupType Disabled
never start it
PS> Set-Service -Name Spooler -StartupType Manual

Get-CimInstance

Query system information through CIM/WMI: OS, BIOS, disks, last boot time.

Syntax: Get-CimInstance <ClassName> [-Filter f]

Alias: gcimBash: uname -a · uptime

Win32_OperatingSystem
OS name, version, last boot
Win32_LogicalDisk
drives and free space
PS> Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, LastBootUpTime

Start-Job

Run a script block in the background while you keep working.

Syntax: Start-Job -ScriptBlock { ... } [-Name n]

Alias: sajbBash: long-command &

-Name
name the job
PS> Start-Job -Name ping -ScriptBlock { Test-Connection github.com -Count 4 }

Receive-Job

Get the output of background jobs. Get-Job lists them.

Syntax: Receive-Job <job> [-Wait] [-AutoRemoveJob]

Alias: rcjbBash: jobs · wait

-Wait
wait for the job to finish
-AutoRemoveJob
delete the job afterwards
PS> Get-Job | Receive-Job -Wait -AutoRemoveJob

Restart-Computer

Restart the local or a remote computer. Stop-Computer shuts it down.

Syntax: Restart-Computer [-ComputerName n] [-Force]

Bash: sudo reboot

-Force
force an immediate restart
-ComputerName
restart a remote machine
PS> Restart-Computer

Careful: Reboots right away and closes open apps, so unsaved work is lost.

Networking

Test-Connection

Ping a host and get the results as objects.

Syntax: Test-Connection <host> [-Count n] [-Quiet]

Bash: ping -c 4 github.com

-Count 4
number of pings
-Quiet
return only True or False
PS> Test-Connection github.com -Count 4

Test-NetConnection

Check whether a TCP port is open on a host (Windows).

Syntax: Test-NetConnection <host> [-Port n] [-TraceRoute]

Alias: tncBash: nc -zv github.com 443

-Port 443
test one TCP port
-TraceRoute
show the network path
PS> Test-NetConnection github.com -Port 443

Resolve-DnsName

Look up DNS records for a domain (Windows).

Syntax: Resolve-DnsName <name> [-Type A|AAAA|MX|TXT|CNAME] [-Server ip]

Bash: dig github.com MX

-Type MX
record type
-Server 1.1.1.1
ask a specific DNS server
PS> Resolve-DnsName github.com -Type MX

Invoke-WebRequest

Download a file or fetch a web page. In Windows PowerShell 5.1, curl and wget are aliases for it; in PowerShell 7 they run the real programs.

Syntax: Invoke-WebRequest <url> [-OutFile path] [-Method m] [-Headers h]

Alias: iwrBash: curl -o file.zip https://example.com/file.zip

-OutFile
save to a file
-UseBasicParsing
avoid the IE engine in 5.1
-Method Head
headers only
PS> Invoke-WebRequest https://example.com/file.zip -OutFile file.zip

Invoke-RestMethod

Call a REST API and get the JSON back as objects you can pipe.

Syntax: Invoke-RestMethod <url> [-Method Post] [-Body b] [-Headers h] [-ContentType c]

Alias: irmBash: curl -s <url> | jq .stargazers_count

-Method Post
HTTP method
-Body
request body
-Headers @{Authorization="Bearer $t"}
add headers
-ContentType application/json
body type
PS> Invoke-RestMethod https://api.github.com/repos/PowerShell/PowerShell | Select-Object stargazers_count

Get-NetIPAddress

Show the IP addresses on each network adapter (Windows). ipconfig still works too.

Syntax: Get-NetIPAddress [-AddressFamily IPv4|IPv6]

Bash: ip -4 addr

-AddressFamily IPv4
IPv4 only
PS> Get-NetIPAddress -AddressFamily IPv4 | Select-Object InterfaceAlias, IPAddress

Get-NetTCPConnection

List TCP connections and listening ports, and find which process holds a port (Windows).

Syntax: Get-NetTCPConnection [-State Listen] [-LocalPort n]

Bash: ss -tlnp · lsof -i :3000

-State Listen
listening ports only
-LocalPort 3000
one port
PS> Get-NetTCPConnection -LocalPort 3000 | Select-Object LocalPort, State, OwningProcess

Get-NetAdapter

List network adapters with status, speed and MAC address (Windows).

Syntax: Get-NetAdapter [-Name n]

Bash: ip link

PS> Get-NetAdapter

Clear-DnsClientCache

Flush the Windows DNS cache, the same as ipconfig /flushdns.

Syntax: Clear-DnsClientCache

Bash: resolvectl flush-caches

PS> Clear-DnsClientCache

Text & objects

Select-String

Search text or files with a regular expression. Case-insensitive by default.

Syntax: Select-String -Pattern <regex> [-Path files] [-Context n] [-CaseSensitive] [-NotMatch]

Alias: slsBash: grep -i 'error' *.log

-Context 2
show 2 lines around each match
-CaseSensitive
match case
-NotMatch
lines that do not match
-SimpleMatch
plain text, not regex
PS> Select-String -Path *.log -Pattern 'error'

Select-Object

Pick properties, or the first or last few objects.

Syntax: Select-Object [-Property p] [-First n] [-Last n] [-ExpandProperty p] [-Unique]

Alias: selectBash: head -n 5 · cut -f1,3

-First 5
first 5 objects
-Last 5
last 5 objects
-ExpandProperty Name
plain values instead of objects
-Unique
drop duplicates
PS> Get-Process | Select-Object Name, Id, CPU -First 5

Sort-Object

Sort objects by one or more properties.

Syntax: Sort-Object [-Property p] [-Descending] [-Unique]

Alias: sortBash: sort -k5 -n · ls -S

-Descending
largest first
-Unique
drop duplicates
PS> Get-ChildItem | Sort-Object Length -Descending

Measure-Object

Count lines, words or objects, or sum and average a property.

Syntax: Measure-Object [-Line] [-Word] [-Character] [-Property p -Sum -Average]

Alias: measureBash: wc -l app.log

-Line
count lines
-Property Length -Sum
total of a property
PS> Get-Content app.log | Measure-Object -Line

Group-Object

Group objects by a property and count each group.

Syntax: Group-Object <property> [-NoElement]

Alias: groupBash: sort | uniq -c

-NoElement
counts only
PS> Get-Service | Group-Object Status

Format-Table

Show output as a table. Use it last: its output is for display and cannot be filtered or saved as data.

Syntax: Format-Table [-Property p] [-AutoSize] [-Wrap]

Alias: ftBash: column -t

-AutoSize
fit columns to content
-Wrap
wrap long values
PS> Get-Process | Format-Table Name, Id, CPU -AutoSize

Format-List

Show each object as a list of property: value lines. Format-List * shows every property.

Syntax: Format-List [-Property p | *]

Alias: fl

*
every property
PS> Get-Service Spooler | Format-List *

ConvertFrom-Json

Turn JSON text into objects you can filter and select.

Syntax: <json> | ConvertFrom-Json [-AsHashtable] [-Depth n]

Bash: jq '{name, version}' package.json

-AsHashtable
return hashtables (PowerShell 6+)
PS> Get-Content package.json -Raw | ConvertFrom-Json | Select-Object name, version

ConvertTo-Json

Turn objects into JSON text.

Syntax: <objects> | ConvertTo-Json [-Depth n] [-Compress]

Bash: jq -n

-Depth 10
default depth is 2; deeper objects become strings
-Compress
one line
PS> Get-Service | Select-Object Name, Status | ConvertTo-Json

Import-Csv

Read a CSV file as objects, one per row, with the header as property names.

Syntax: Import-Csv <path> [-Delimiter c]

Bash: awk -F, '$3=="IT"' users.csv

-Delimiter ";"
a different separator
PS> Import-Csv users.csv | Where-Object Department -eq 'IT'

Export-Csv

Save objects to a CSV file.

Syntax: <objects> | Export-Csv <path> [-NoTypeInformation] [-Append]

-NoTypeInformation
skip the #TYPE line in Windows PowerShell 5.1
-Append
add rows instead of replacing
PS> Get-Process | Select-Object Name, CPU | Export-Csv procs.csv -NoTypeInformation

Careful: Replaces an existing file unless you add -Append.

-replace

Find and replace with a regular expression. The parentheses read the whole file before it is written back.

Syntax: <text> -replace <regex>, <replacement>

Bash: sed -i 's/localhost/db01/g' config.txt

-creplace
case-sensitive
-split
split text on a regex
PS> (Get-Content config.txt) -replace 'localhost', 'db01' | Set-Content config.txt

Write-Output

Send a value down the pipeline. Write-Host prints to the screen only, so its text cannot be captured.

Syntax: Write-Output <value>

Alias: echo, writeBash: echo 'Build finished'

PS> Write-Output 'Build finished'

Get-Date

Get the current date and time, format it, or do date math.

Syntax: Get-Date [-Format f] [-UFormat f]

Bash: date '+%Y-%m-%d %H:%M'

-Format yyyy-MM-dd
.NET format string
.AddDays(-7)
date math
PS> Get-Date -Format 'yyyy-MM-dd HH:mm'

Tee-Object

Save output to a file or variable and also pass it down the pipeline.

Syntax: <command> | Tee-Object <path> [-Append]

Alias: teeBash: tee procs.txt

-Variable name
save to a variable instead
PS> Get-Process | Tee-Object procs.txt | Sort-Object CPU

Set-Clipboard

Copy text to the clipboard. Get-Clipboard pastes it.

Syntax: <text> | Set-Clipboard

Alias: scbBash: pbcopy · xclip -sel clip

PS> Get-Content ~\.ssh\id_ed25519.pub | Set-Clipboard

Out-GridView

Open output in a sortable, filterable window (Windows).

Syntax: <command> | Out-GridView [-PassThru]

Alias: ogv

-PassThru
send the rows you pick down the pipeline
PS> Get-Process | Out-GridView

Pipeline & filtering

Where-Object

Keep only the objects that match a condition.

Syntax: <command> | Where-Object <property> -eq <value> · Where-Object { $_.prop -gt n }

Alias: where, ?Bash: grep Running

-eq / -ne
equal / not equal
-like
wildcard match
-match
regex match
PS> Get-Service | Where-Object Status -eq 'Running'

ForEach-Object

Run a script block once for each object in the pipeline.

Syntax: <command> | ForEach-Object { ... $_ ... } [-Parallel { }]

Alias: foreach, %Bash: for f in *.txt; do ...; done

-Parallel
run in parallel (PowerShell 7)
-ThrottleLimit 5
max parallel runs
PS> Get-ChildItem *.txt | ForEach-Object { $_.Name.ToUpper() }

$_

The current object inside Where-Object, ForEach-Object and other script blocks.

Syntax: { $_.<property> }

Alias: $PSItemBash: $0 in awk

PS> Get-Process | Where-Object { $_.WorkingSet64 -gt 500MB }

-eq / -like / -match

Comparison operators. PowerShell does not use == or >; they are -eq, -ne, -gt, -lt, -like (wildcards) and -match (regex). All ignore case unless you use -ceq, -clike or -cmatch.

Syntax: <value> -eq | -ne | -gt | -lt | -like | -match <value>

Bash: == · [[ $f == *.pdf ]] · =~

-gt / -lt
greater / less than
-contains
list contains a value
-in
value is in a list
PS> 'report.pdf' -like '*.pdf'

-WhatIf

Show what a command would change without changing anything. -Confirm asks before each change. Works on most cmdlets that change things.

Syntax: <cmdlet> ... -WhatIf · <cmdlet> ... -Confirm

Bash: rm -i (closest)

-Confirm
ask before each change
PS> Get-ChildItem *.tmp | Remove-Item -WhatIf

Compare-Object

Show the differences between two sets of objects, such as the lines of two files.

Syntax: Compare-Object <reference> <difference> [-IncludeEqual]

Alias: compare, diffBash: diff a.txt b.txt

-IncludeEqual
also list matching items
PS> Compare-Object (Get-Content a.txt) (Get-Content b.txt)

Scripts, variables & execution policy

Get-ExecutionPolicy

Show the policy that decides whether scripts can run, for each scope.

Syntax: Get-ExecutionPolicy [-List] [-Scope s]

-List
every scope at once
PS> Get-ExecutionPolicy -List

Set-ExecutionPolicy

Allow scripts to run. RemoteSigned for CurrentUser lets your own scripts run while downloaded ones must be signed. Fixes "running scripts is disabled on this system".

Syntax: Set-ExecutionPolicy RemoteSigned|AllSigned|Restricted|Bypass -Scope CurrentUser|LocalMachine|Process

-Scope CurrentUser
only you, no admin needed
-Scope Process
only this window
PS> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Careful: Lowers script protection for that scope. Unrestricted or Bypass runs any script, downloaded ones included. Prefer RemoteSigned for CurrentUser.

Unblock-File

Remove the "downloaded from the internet" mark so RemoteSigned lets a script run.

Syntax: Unblock-File <path>

PS> Unblock-File .\install.ps1

Careful: Only unblock scripts from a source you trust and have read.

.\script.ps1

Run a script in the current folder. PowerShell never runs scripts from the current folder by bare name, so the .\ is required.

Syntax: .\<script>.ps1 [arguments]

Bash: ./build.sh

PS> .\build.ps1 -Configuration Release

. .\script.ps1

Dot-source a script: run it in the current scope so its functions and variables stay defined. Use it to reload your profile.

Syntax: . <path>

Bash: source ~/.bashrc

PS> . $PROFILE

pwsh -File

Run a script in a new PowerShell process. pwsh is PowerShell 7; powershell.exe is Windows PowerShell 5.1.

Syntax: pwsh [-NoProfile] [-ExecutionPolicy p] -File <script> | -Command <text>

Bash: bash build.sh

-NoProfile
skip your profile for a clean, fast start
-Command
run a one-liner instead
PS> pwsh -NoProfile -File .\build.ps1

$env:VAR

Read or set an environment variable for this session. Get-ChildItem Env: lists them all.

Syntax: $env:<NAME> · $env:<NAME> = "value"

Bash: export NODE_ENV=production

Get-ChildItem Env:
list every variable (like env)
$env:Path += ";C:\tools"
add a folder to PATH for this session
PS> $env:NODE_ENV = 'production'

$PROFILE

The path of your profile script, which runs in every new session. Put aliases, functions and prompt settings there.

Syntax: $PROFILE

Bash: nano ~/.bashrc

Test-Path $PROFILE
check whether it exists yet
PS> notepad $PROFILE

Measure-Command

Time how long a script block takes to run.

Syntax: Measure-Command { ... }

Bash: time npm run build

PS> Measure-Command { npm run build }

Start-Sleep

Pause a script for some seconds or milliseconds.

Syntax: Start-Sleep -Seconds n | -Milliseconds n

Alias: sleepBash: sleep 5

PS> Start-Sleep -Seconds 5

Read-Host

Ask the user for input in a script.

Syntax: Read-Host [prompt] [-AsSecureString]

Bash: read -p 'Your name: ' name

-AsSecureString
hide what is typed
PS> $name = Read-Host 'Your name'

Invoke-Expression

Run a string as PowerShell code. Installers often pipe downloaded scripts into it.

Syntax: Invoke-Expression <string>

Alias: iexBash: eval

PS> Invoke-Expression 'Get-Date'

Careful: irm <url> | iex runs downloaded code you have not read, with your permissions. Download the script, read it, then run it.

Modules & packages

Get-Module

List loaded modules, or every installed module with -ListAvailable.

Syntax: Get-Module [name] [-ListAvailable]

Alias: gmo

-ListAvailable
installed, not just loaded
PS> Get-Module -ListAvailable

Import-Module

Load a module into this session. Most modules load automatically when you call one of their commands.

Syntax: Import-Module <name|path> [-Force]

Alias: ipmoBash: source lib.sh

-Force
reload after changes
PS> Import-Module Pester

Find-Module

Search the PowerShell Gallery for modules.

Syntax: Find-Module [name] [-Tag t]

Bash: apt search

-Tag
search by tag
PS> Find-Module PSReadLine

Install-Module

Install a module from the PowerShell Gallery.

Syntax: Install-Module <name> [-Scope CurrentUser] [-Force]

Bash: pip install --user

-Scope CurrentUser
no admin needed
-Force
reinstall over an existing version
PS> Install-Module Pester -Scope CurrentUser

Careful: Gallery modules are community code that runs with your permissions. Check the author and download count first.

Update-Module

Update an installed Gallery module to its latest version.

Syntax: Update-Module [name]

Bash: pip install -U

PS> Update-Module PSReadLine

Uninstall-Module

Remove a module installed from the Gallery.

Syntax: Uninstall-Module <name> [-AllVersions]

Bash: pip uninstall

-AllVersions
every installed version
PS> Uninstall-Module Pester

winget install

Install apps with the Windows Package Manager. Not a cmdlet, but the usual way to install tools from PowerShell.

Syntax: winget install --id <id> [-e] [--silent]

Bash: sudo apt install git

--id
exact package ID
-e
exact match
winget search
find the ID first
PS> winget install --id Git.Git -e

winget upgrade

List apps with updates, or upgrade them.

Syntax: winget upgrade [--id id] [--all]

Bash: sudo apt upgrade

--all
upgrade everything
PS> winget upgrade --all

Remoting & system admin

Enter-PSSession

Open an interactive shell on a remote computer. Exit-PSSession leaves it.

Syntax: Enter-PSSession -ComputerName <name> [-Credential c] · -HostName <ssh-host>

Alias: etsnBash: ssh server01

-Credential
sign in as another user
-HostName
connect over SSH (PowerShell 7)
PS> Enter-PSSession -ComputerName server01

Invoke-Command

Run a script block on one or many remote computers at once.

Syntax: Invoke-Command -ComputerName <names> -ScriptBlock { ... } [-Credential c]

Alias: icmBash: ssh server01 'systemctl status cups'

-ComputerName a, b
several machines in parallel
-FilePath
run a local script remotely
PS> Invoke-Command -ComputerName server01, server02 -ScriptBlock { Get-Service Spooler }

Careful: Runs on every listed machine at the same time. Try a change on one machine first.

Enable-PSRemoting

Turn on WinRM so this machine accepts remote PowerShell sessions. Needs an elevated session.

Syntax: Enable-PSRemoting [-Force]

-Force
skip the prompts
PS> Enable-PSRemoting -Force

Careful: Lets administrators on the network run commands on this machine and adds firewall rules. Only enable it where you need it.

Get-Credential

Prompt for a user name and password and store them as a credential object for -Credential.

Syntax: Get-Credential [user]

PS> $cred = Get-Credential

Get-WinEvent

Read Windows event logs: System, Application, Security and more.

Syntax: Get-WinEvent -LogName <log> [-MaxEvents n] [-FilterHashtable h]

Bash: journalctl -n 20

-MaxEvents 20
newest 20
-FilterHashtable @{LogName="System"; Level=2}
errors only
PS> Get-WinEvent -LogName System -MaxEvents 20

Get-LocalUser

List local user accounts and whether they are enabled.

Syntax: Get-LocalUser [-Name n]

Bash: cut -d: -f1 /etc/passwd

PS> Get-LocalUser

Start-Transcript

Record everything in this session to a log file until Stop-Transcript.

Syntax: Start-Transcript [-Path p] [-Append]

Bash: script session.log

-Append
add to an existing log
PS> Start-Transcript -Path .\session.log

Verb-Noun: how PowerShell commands are named

Every cmdlet is an approved verb plus a noun: Get-Service reads services, Stop-Service stops one and Set-Service changes one. Once you know the noun, Get-Command -Noun Service lists every command for it. Cmdlets pass objects, not text, so you filter with Where-Object and pick fields with Select-Object instead of grep and cut. Parameter names can be shortened while they stay unique, and tab completion fills them in.

How to use this PowerShell command list

  1. 1. Search by cmdlet, alias or task

    Type a cmdlet such as Get-Process, an alias such as ls, a Bash command such as grep, or a task such as port or zip.

  2. 2. Filter by category

    Pick a category such as Files & folders or Networking to narrow the list.

  3. 3. Check the alias, Bash equivalent and syntax

    See the short alias, the closest Bash command and the parameters people actually use. Read any Careful note.

  4. 4. Copy the example

    Copy the example, change the names and paths to yours and run it in PowerShell. Add -WhatIf first on anything that changes files.

PowerShell commands FAQ

What are the most useful PowerShell commands?

Start with Get-Help, Get-Command and Get-Member to discover anything else. Then Get-ChildItem, Set-Location, Copy-Item, Remove-Item and Get-Content for files, Get-Process and Get-Service for what is running, and Where-Object, Select-Object and Sort-Object to filter output.

What is the PowerShell equivalent of ls, grep and cat?

ls is Get-ChildItem, grep is Select-String, cat is Get-Content, ps is Get-Process, kill is Stop-Process and curl is Invoke-WebRequest. On Windows, PowerShell defines ls, cat, ps and kill as aliases, so the Linux names often work.

Why do ls and cat not work in PowerShell on Linux or macOS?

PowerShell 7 removes aliases such as ls, cat, ps, kill, sort and curl on Linux and macOS so the native programs run instead. Use the full cmdlet names, such as Get-ChildItem, in scripts that must run everywhere.

How do I fix "running scripts is disabled on this system"?

Run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser. Your own scripts can then run while downloaded scripts must be signed or unblocked with Unblock-File. Avoid Unrestricted and Bypass, which allow any script.

What is the difference between PowerShell and Command Prompt?

Command Prompt (cmd.exe) passes plain text between commands. PowerShell passes objects with properties, so you can filter with Where-Object and pick fields with Select-Object instead of parsing text. Most cmd commands, like ipconfig and ping, still work inside PowerShell.

Which PowerShell commands are dangerous?

Remove-Item -Recurse -Force deletes folders with no undo, Stop-Process ends programs without saving, Set-ExecutionPolicy Bypass lets any script run, and irm <url> | iex runs downloaded code unseen. Add -WhatIf to see what a command would do first.

Automate the PowerShell steps you repeat

Running the same build, test and deploy commands by hand on Windows? Tornic turns those steps into deterministic multi-step workflows that run on the Claude Code, Codex or Cursor CLI you already pay for.

Explore Tornic

Related free tools