ShareYourGroupShareYourGroupCommands

Guides

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.

CmdletDoes
Get-ChildItemlists a folder
Set-Locationchanges folder
Copy-Itemcopies
Move-Itemmoves or renames
Remove-Itemdeletes
Get-Contentshows a file
Get-Processlists running programs
Stop-Processends a program
Get-Servicelists Windows services
Get-Helpexplains 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 typeIt runs
dir, lsGet-ChildItem
cdSet-Location
copy, cpCopy-Item
move, mvMove-Item
del, rmRemove-Item
type, catGet-Content
cls, clearClear-Host
echoWrite-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.

Windows Command Prompt not run here
Get-Alias dir
Get-Alias -Definition Get-ChildItem

Options 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.

Windows Command Prompt not run here
Get-ChildItem -Recurse -Filter *.txt
Copy-Item notes.txt backup -Verbose
Remove-Item old -Recurse

The 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.

Windows Command Prompt not run here
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 -Sum

In 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

Windows Command Prompt not run here
Get-Help Copy-Item -Examples
Get-Command *process*
Get-ChildItem | Get-Member

-WhatIf: see before you do

Cmdlets that change things accept -WhatIf. With it, the command reports what it would do and does nothing.

Windows Command Prompt not run here
Remove-Item *.tmp -WhatIf
Remove-Item old -Recurse -WhatIf

It 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.

Windows Command Prompt not run here
$name = "Asha"
"Hello, $name"
$files = Get-ChildItem *.txt
$files.Count
$env:USERNAME

Environment 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:

Windows Command Prompt not run here
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

RemoteSigned 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

ToType
find big filesGet-ChildItem -Recurse | Sort-Object Length -Descending | Select-Object -First 10 FullName, Length
search inside filesSelect-String -Path *.txt -Pattern "error"
last 20 lines of a fileGet-Content log.txt -Tail 20
follow a logGet-Content log.txt -Wait
free space on drivesGet-Volume
which program a name runsGet-Command notepad
your command historyGet-History
stop a programStop-Process -Name notepad

PowerShell or Command Prompt?

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.