The PowerShell commands you need first are Get-ChildItem (list files), Set-Location (change folder), Get-Content (read a file), Copy-Item, Move-Item and Remove-Item (manage files), Select-String (search text) and Get-Process (see what's running). When you forget one, Get-Command finds it and Get-Help explains it.
Every built-in command (a "cmdlet") is named Verb-Noun, and most have short aliases borrowed from cmd and Unix, so ls, dir and cd already work. The examples below were run in Windows PowerShell 5.1 on Windows 11; they work the same in PowerShell 7.
Basic PowerShell commands cheat sheet
| Task | Cmdlet | Alias |
|---|---|---|
| List files and folders | Get-ChildItem | ls, dir, gci |
| Change folder | Set-Location | cd |
| Show current folder | Get-Location | pwd |
| Read a file | Get-Content | cat |
| Create a file or folder | New-Item | |
| Copy | Copy-Item | cp |
| Move or rename | Move-Item, Rename-Item | mv |
| Delete | Remove-Item | rm |
| Search text in files | Select-String | |
| List processes | Get-Process | ps |
| Stop a process | Stop-Process | kill |
| Print text | Write-Output | echo |
| Help for a command | Get-Help | help, man |
| Find a command | Get-Command |
The aliases come from running Get-Alias ls, dir, cd, cat, rm, cp, mv, ps, kill, pwd, echo, man. An alias only renames the cmdlet; it doesn't bring the Unix flags along. ls -la fails, because Get-ChildItem has no -la parameter. Use Get-ChildItem -Force to include hidden files.
Find any command: Get-Command and Get-Help
Microsoft's own PowerShell 101 guide calls Get-Help, Get-Command and Get-Member the three core cmdlets, because they let you discover everything else. Search by verb or noun:
Get-Command -Noun Process
Example output:
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Debug-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Start-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Stop-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Wait-Process 3.1.0.0 Microsoft.PowerShell.Management
Wildcards work too: Get-Command *service*. Then read the examples for the one you picked:
Get-Help Get-ChildItem -Examples
Help files aren't preinstalled. Until you run Update-Help, Get-Help shows only the syntax and a note that it "cannot find the Help files for this cmdlet on this computer". In Windows PowerShell 5.1 Update-Help needs an administrator session. Get-Help Get-ChildItem -Online opens the current page on Microsoft Learn without installing anything.
Navigate and list files
Set-Location C:\work
Get-ChildItem
Example output:
Mode Length Name
---- ------ ----
-a---- 11 f1.txt
-a---- 11 f2.txt
-a---- 11 f3.txt
-a---- 36 log.txt
Useful variations:
Get-ChildItem -Filter *.txt # only .txt files
Get-ChildItem -Recurse -File # all files in all subfolders
Get-ChildItem -Name # names only
Get-ChildItem | Sort-Object Length -Descending | Select-Object -First 5
The last line works because Get-ChildItem returns file objects, and Length is a real number property, not text you have to parse. For a full walkthrough of hunting down space hogs, see how to find large files.
Create, copy, move, rename and delete
New-Item -ItemType Directory reports
New-Item -ItemType File notes.txt
Copy-Item f1.txt f1-copy.txt
Rename-Item f1-copy.txt renamed.txt
Move-Item renamed.txt reports\
Remove-Item notes.txt
Remove-Item doesn't use the Recycle Bin. Before deleting with a wildcard, add -WhatIf to see what would happen without doing it:
Remove-Item *.txt -WhatIf
What if: Performing the operation "Remove File" on target "C:\work\f1.txt".
What if: Performing the operation "Remove File" on target "C:\work\f2.txt".
What if: Performing the operation "Remove File" on target "C:\work\f3.txt".
What if: Performing the operation "Remove File" on target "C:\work\log.txt".
Deleting a folder that has contents needs -Recurse. Use Test-Path notes.txt to check whether something exists; it returns True or False.
Read and search files: Get-Content and Select-String
Get-Content log.txt # whole file
Get-Content log.txt -TotalCount 2 # first 2 lines, like head
Get-Content log.txt -Tail 20 # last 20 lines, like tail
Get-Content app.log -Wait -Tail 10 # follow a growing log, like tail -f
Select-String is PowerShell's grep. It prints the file, line number and matching line:
Select-String -Path log.txt -Pattern 'error'
log.txt:3:gamma error
The pattern is a regular expression and case-insensitive by default; add -CaseSensitive to change that, or -SimpleMatch to search for literal text. Search a whole tree with Get-ChildItem -Recurse -Filter *.log | Select-String 'timeout'.
Processes: Get-Process and Stop-Process
Get-Process | Sort-Object WorkingSet64 -Descending | Select-Object -First 3 Name, Id, @{n='MB';e={[math]::Round($_.WorkingSet64/1MB)}}
Example output:
Name Id MB
---- -- --
Memory Compression 3568 3192
vmmemWSL 1588 1450
MsMpEng 11144 825
This is the pipeline at work: Get-Process emits process objects, Sort-Object orders them by a property, and Select-Object picks columns, including a calculated one that converts bytes to MB. Stop a process by ID or name:
Stop-Process -Id 18244
Stop-Process -Name notepad
If what you're really after is the process holding a network port, fixing "port already in use" shows the Get-NetTCPConnection one-liner.
Filter and inspect: Where-Object, Select-Object, Get-Member
Get-ChildItem -File | Where-Object Length -gt 1MB
Get-Service | Where-Object Status -eq 'Running'
Get-Item log.txt | Get-Member
Where-Object filters objects by a property. Comparison operators are words: -eq, -ne, -gt, -lt, -like (wildcards), -match (regex). Get-Member lists every property and method an object has, which is how you find out that a file has Length, LastWriteTime and Extension to filter on.
Count and sum with Measure-Object:
Get-ChildItem -Filter *.txt | Measure-Object -Property Length -Sum
Count Sum
----- ---
4 69
Variables and environment variables
$name = "alex"
"Hello, $name" # double quotes expand variables
'Hello, $name' # single quotes don't
$env:PATH # read an environment variable
$env:APP_MODE = "dev" # set one for this session only
Setting $env: lasts only until the window closes. To set one permanently, see how to set environment variables.
Running scripts: execution policy
A PowerShell script is a .ps1 file. Run it with .\script.ps1; the .\ is required, because PowerShell doesn't run scripts from the current folder by name alone (typing hello.ps1 gives the "is not recognized" error). If scripts are blocked, you'll see:
File C:\work\hello.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
That's the execution policy. According to Microsoft's documentation, when no policy is set the effective policy on Windows clients is Restricted, which allows individual commands but no scripts. Check yours with:
Get-ExecutionPolicy -List
To allow your own scripts for your user account only:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
RemoteSigned runs scripts written locally and requires a signature on scripts downloaded from the internet. Microsoft notes that the execution policy isn't a security boundary; it stops accidental script runs, not a determined attacker.
If a command doesn't behave as expected
The term 'grepx' is not recognized as the name of a cmdlet, function, script file, or operable program.The command doesn't exist in this session. Check the spelling withGet-Command *partname*, or install the module that provides it.Cannot find path 'C:\work\nope.txt' because it does not exist.The path is relative to the current location; runGet-Locationto check where you are.curlbehaves strangely: in Windows PowerShell 5.1,curlandwgetare aliases forInvoke-WebRequest, which takes different parameters. Typecurl.exeto run the real curl program instead (on Windows 11 it's atC:\Windows\System32\curl.exe).
Frequently asked questions
- What is the difference between PowerShell and Command Prompt?
- Command Prompt (cmd.exe) passes text between commands. PowerShell passes .NET objects, so you can sort, filter and select properties such as file size or process memory without parsing text. Most cmd commands, like ipconfig and ping, still work inside PowerShell because they are ordinary programs.
- Is PowerShell case-sensitive?
- No. Command names, parameter names and most string comparisons are case-insensitive by default: get-childitem, Get-ChildItem and GET-CHILDITEM all run the same cmdlet. Use operators such as -ceq or -cmatch when you need a case-sensitive comparison.
- What is the difference between powershell.exe and pwsh.exe?
- powershell.exe is Windows PowerShell 5.1, which ships with Windows. pwsh.exe is PowerShell 7, a separate cross-platform install that also runs on macOS and Linux. Microsoft renamed the executable to pwsh.exe so both versions can be installed side by side.
- How do I see the full output of a command that gets cut off?
- Pipe it to Format-List to show every property one per line, for example Get-Process -Id 1234 | Format-List *. For tables that are truncated, use Format-Table -AutoSize or Out-String -Width 200.