PowerShell for Windows users: your first five commands
Open the terminal without fear and get useful answers from Windows in seconds.
PowerShell is built into Windows. Press the Windows key, type PowerShell (or Terminal), and press Enter. Here are five commands to start with.
PowerShell commands follow a Verb-Noun pattern: Get-Something, Set-Something. Once you notice that, you can often guess a command’s name.
1. Get-Location: where am I?
Get-Location
This shows the folder you’re in, for example C:\Users\Sam.
2. Get-ChildItem: what’s here?
Get-ChildItem
This lists the files and folders where you are. The short form ls works too.
3. Set-Location: move around
Set-Location Documents
Set-Location ..
The first line moves into Documents, and the second moves back up one level. The short form is cd.
4. Get-Help: ask PowerShell
Get-Help Get-ChildItem -Examples
This shows real examples for any command. It’s your built-in teacher.
5. Get-Process: what’s running?
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5
In plain English
Get every running program, sort them by how much CPU they’ve used (biggest first), and show only the top five. The | symbol, called a pipe, passes the results of one command into the next.
The pipe is PowerShell’s superpower. Small commands snap together like LEGO.
"Running scripts is disabled on this system"?
Windows blocks .ps1 script files by default. To allow scripts that you wrote yourself, run this once: Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.
Try it yourself
List only the .txt files in your Documents folder with Get-ChildItem ~\Documents -Filter *.txt.