PowerShell for Command Prompt users
PowerShell is the newer of Windows' two command lines, and the one Microsoft now develops. The Command Prompt still works and its commands are the ones most often quoted online, which is why this site's Windows pages use it. But PowerShell is more capable, more consistent and safer to experiment with. This guide is a bridge for someone who knows a little of the Command Prompt.
The examples here are shown as you would type them. They were not run for this page.
Opening it
Press Win + X and choose Terminal or Windows PowerShell. The prompt begins with PS, as in PS C:\Users\asha>.
Most Command Prompt commands still work when typed into PowerShell, because the programs behind them, such as ipconfig, ping and robocopy, are separate files that either shell can start.
Commands are verb and noun
PowerShell's own commands are called cmdlets, and they are named as a verb, a dash and a noun.
| Cmdlet | Does |
|---|---|
Get-ChildItem | lists a folder |
Set-Location | changes folder |
Copy-Item | copies |
Move-Item | moves or renames |
Remove-Item | deletes |
Get-Content | shows a file |
Get-Process | lists running programs |
Stop-Process | ends a program |
Get-Service | lists Windows services |
Get-Help | explains a command |
The names are long, and predictable. If you know Get-Process, you can guess Stop-Process. Pressing Tab completes them, so Get-Ch and Tab is enough.
Aliases: the names you already know
PowerShell gives short aliases to its common cmdlets, taken from both the Command Prompt and Linux.
| You can type | It runs |
|---|---|
dir, ls | Get-ChildItem |
cd | Set-Location |
copy, cp | Copy-Item |
move, mv | Move-Item |
del, rm | Remove-Item |
type, cat | Get-Content |
cls, clear | Clear-Host |
echo | Write-Output |
So dir, cd and copy work at once. The options are PowerShell's own, though. dir /b is an error. The PowerShell way is Get-ChildItem -Name.
Get-Alias dir
Get-Alias -Definition Get-ChildItemOptions are words
Options begin with a dash and are spelt out: -Recurse, -Force, -Filter. They can be shortened as far as they stay unambiguous, and Tab completes them.
Get-ChildItem -Recurse -Filter *.txt
Copy-Item notes.txt backup -Verbose
Remove-Item old -RecurseThe pipeline carries objects, not text
This is the real difference. In the Command Prompt and in Linux, a pipe passes lines of text. In PowerShell it passes objects, things with named properties. That means you can sort, filter and select by property without cutting up text.
Get-ChildItem | Sort-Object Length -Descending | Select-Object -First 5 Name, Length
Get-Process | Where-Object { $_.WorkingSet -gt 500MB } | Sort-Object WorkingSet -Descending
Get-ChildItem -Recurse | Measure-Object Length -SumIn order: the five largest files here; the processes using more than 500 MB of memory; and the total size of everything below the current folder. $_ means "the current item". PowerShell understands KB, MB and GB.
To see what properties an object has, pipe it to Get-Member.
Three cmdlets that teach you the rest
Get-Help Copy-Item -Examples
Get-Command *process*
Get-ChildItem | Get-MemberGet-Helpexplains a command.-Examplesshows worked examples, and-Onlineopens the full page in a browser.Get-Commandfinds commands by name or pattern.Get-Membershows what an object contains.
-WhatIf: see before you do
Cmdlets that change things accept -WhatIf. With it, the command reports what it would do and does nothing.
Remove-Item *.tmp -WhatIf
Remove-Item old -Recurse -WhatIfIt prints lines such as "What if: Performing the operation Remove File on target ...". Read them, and then run the command again without -WhatIf. -Confirm asks about each item instead. This is the best safety feature of any command line, and a strong reason to prefer PowerShell for anything that deletes.
Danger. Remove-Item -Recurse -Force is PowerShell's equivalent of rm -rf. It deletes a folder tree, including hidden and read-only files, with no Recycle Bin. Run it with -WhatIf first.
Variables
Variables begin with a dollar sign and can hold anything, including the result of a command.
$name = "Asha"
"Hello, $name"
$files = Get-ChildItem *.txt
$files.Count
$env:USERNAMEEnvironment variables are read as $env:NAME, where the Command Prompt uses %NAME%.
Scripts and the execution policy
A PowerShell script is a text file ending in .ps1. On a new Windows computer, trying to run one gives an error saying that running scripts is disabled. This is the execution policy, a safety catch against running scripts by accident.
To allow scripts you write yourself, for your own account only:
Set-ExecutionPolicy -Scope CurrentUser RemoteSignedRemoteSigned lets local scripts run and requires downloaded ones to be signed. Do not set the policy to Unrestricted or Bypass because a website says so.
A script in the current folder is run as .\name.ps1, with the dot and backslash. PowerShell, like Linux, does not run programs from the current folder by name alone.
Danger. Treat a .ps1 file from an email, a download or a chat message like any other program from a stranger. Open it in Notepad and read it before running it. A PowerShell command that includes -EncodedCommand, or iex together with a web address, is hiding what it does, and is a common sign of malicious code.
Useful one-liners
| To | Type |
|---|---|
| find big files | Get-ChildItem -Recurse | Sort-Object Length -Descending | Select-Object -First 10 FullName, Length |
| search inside files | Select-String -Path *.txt -Pattern "error" |
| last 20 lines of a file | Get-Content log.txt -Tail 20 |
| follow a log | Get-Content log.txt -Wait |
| free space on drives | Get-Volume |
| which program a name runs | Get-Command notepad |
| your command history | Get-History |
| stop a program | Stop-Process -Name notepad |
PowerShell or Command Prompt?
- Following instructions written for
cmd: use the Command Prompt, or type the same line into PowerShell, where most of them work. - Writing something new, especially anything with a loop or a condition: use PowerShell.
- Anything that deletes or changes many files: PowerShell, for
-WhatIf.
PowerShell also runs on Linux and the Mac, as a separate download, with the same cmdlets.
Examples shown with output were run on 12 November 2026 in a practice folder: Windows commands in cmd.exe on Windows 11, Linux commands with the GNU tools of Git Bash. The folder path and user name were replaced with made-up ones. Commands marked "not run here" are shown as you would type them.
This is an independent learning site. It is not connected with Microsoft, Apple or any Linux distribution. Windows, macOS and other names belong to their owners. Try commands first in a practice folder, never on files you cannot afford to lose.