Skip to content

Command Line

PowerShell Cheatsheet

Essential PowerShell commands for file operations, processes, and system management.

native Client-side

Navigation & Paths

5
Get-Location

Get current directory (aliases: pwd, gl).

Set-Location -Path C:\path

Change directory to specified path (aliases: cd, sl).

Push-Location -Path C:\path

Push current directory onto stack and change directory (alias: pushd).

Pop-Location

Restore last pushed directory from stack (alias: popd).

Resolve-Path .\file.txt

Resolve wildcard paths to absolute paths.

File & Directory Operations

10
Get-ChildItem

List files and directories in current path (aliases: ls, dir, gci).

Get-ChildItem -Recurse -Filter *.log

Find all log files recursively.

New-Item -Path .\newfile.txt -ItemType File

Create a new empty file (alias: ni).

New-Item -Path .\NewFolder -ItemType Directory

Create a new empty folder.

Remove-Item -Path .\file.txt -Force

Delete file or directory (aliases: rm, del, ri).

Copy-Item -Path .\src.txt -Destination .\dest.txt

Copy file or folder (aliases: cp, copy, mi).

Move-Item -Path .\file.txt -Destination .\archive\

Move file or folder (aliases: mv, move).

Get-Content -Path .\file.txt -Tail 10

Output the content of a file (aliases: cat, gc).

Set-Content -Path .\file.txt -Value "Hello"

Write or replace content in a file (alias: sc).

Add-Content -Path .\file.txt -Value "Line"

Append line to a file (alias: ac).

System & Process Management

7
Get-Process

Get list of active processes (aliases: ps, gps).

Get-Process -Name chrome

Find active processes named "chrome".

Stop-Process -Id 1234

Terminate process by ID (aliases: kill, spps).

Stop-Process -Name notepad

Terminate process by name.

Get-Service

List all system services (alias: gsv).

Start-Service -Name wuauserv

Start a system service (alias: sasv).

Stop-Service -Name wuauserv

Stop a system service (alias: spsv).

Package & Module Management

5
Install-Module -Name Az

Install a module from PowerShell Gallery.

Uninstall-Module -Name Az

Uninstall a module.

Get-InstalledModule

List modules installed on system.

Find-Module -Name *SQL*

Search the PS Gallery for modules matching name.

Import-Module -Name Az

Import a module into current session.

Networking

4
Test-Connection -ComputerName google.com

Ping remote host (alias: ping).

Resolve-DnsName -Name google.com

Perform DNS lookup (alias: nslookup).

Invoke-WebRequest -Uri https://api.github.com

Send HTTP request (aliases: curl, wget, iwr).

Invoke-RestMethod -Uri https://api.github.com

Send HTTP request and parse JSON payload (alias: irm).

Essential PowerShell Commands Cheatsheet

PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and a scripting language. This searchable cheatsheet covers cmdlets for file manipulation, system processes, module management, and network utilities.

Frequently Asked Questions

What is the difference between cmdlets and traditional commands?

PowerShell uses cmdlets (pronounced command-lets), which are built-in .NET classes. Unlike Unix shell commands or Windows CMD commands that return text output, cmdlets output structured objects. This allows you to easily pipe object properties between cmdlets.

How do I get help on a command?

Use Get-Help <cmdlet-name> (or its alias help) to display syntax, descriptions, and examples. Add the -Online flag to open Microsoft's documentation in your web browser.