keepcalculator

06 Numbers and Powers

Essential PowerShell Commands: The 25 You’ll Use Daily

Card No. 06·42264 · Updated · Standard formula, shown below

Essential PowerShell commands are the core cmdlets you need to navigate the filesystem, manage processes, and inspect system state from the command line. This article lists the 25 most frequently used commands, explains what each does, and shows realistic examples so you can start scripting productively today.

Background: Why PowerShell Commands Matter

PowerShell is Microsoft’s task automation and configuration management framework, built on the .NET runtime. Unlike the classic Command Prompt (cmd.exe), which outputs plain text, PowerShell works with objects—structured data that retains properties and methods. This object-oriented design means you can pipe output from one command directly into another, filter it, and format it without parsing text. For system administrators and power users, mastering a handful of essential commands unlocks the ability to automate repetitive tasks, manage remote machines, and build complex scripts with minimal effort.

How PowerShell Commands Work: Cmdlets, Aliases, and Piping

PowerShell commands are called cmdlets (pronounced “command-lets”). They follow a consistent Verb-Noun naming convention, such as Get-Process, Set-Location, or Remove-Item. This makes it easy to guess what a command does: Get retrieves data, Set assigns a value, New creates something, and Remove deletes it.

Cmdlets accept parameters (e.g., -Path, -Filter) and output objects. The pipe character (|) passes the output of one cmdlet to the next, enabling powerful one-liners. For example, Get-Process | Where-Object {$_.CPU -gt 100} finds processes using more than 100 seconds of CPU time. Aliases provide short names for common cmdlets (e.g., gci for Get-ChildItem, cls for Clear-Host), but using full names in scripts improves readability.

The 25 Essential Commands (Grouped by Task)

Here are the commands you’ll use most often, grouped by what they do. For each, we show the full name, a common alias, and a brief example.

File System Navigation and Management

  • Get-Location (pwd) – Shows your current directory path. Example: Get-Location
  • Set-Location (cd) – Changes the current directory. Example: Set-Location C:\Users\Public
  • Get-ChildItem (dir, ls) – Lists files and folders in a directory. Use -Recurse to include subdirectories. Example: Get-ChildItem -Path C:\Windows -Filter *.log -Recurse
  • New-Item (ni) – Creates a new file or folder. Example: New-Item -Path .\backup -ItemType Directory
  • Copy-Item (copy, cp) – Copies files or folders. Example: Copy-Item -Path .\report.docx -Destination D:\Archive
  • Move-Item (move, mv) – Moves a file or folder. Example: Move-Item -Path .\old.log -Destination .\logs\old.log
  • Remove-Item (del, rm) – Deletes files or folders. Use -Recurse for non-empty folders. Example: Remove-Item -Path .\temp -Recurse -Force
  • Rename-Item (ren) – Renames a file or folder. Example: Rename-Item -Path .\draft.txt -NewName final.txt
  • Get-Content (cat, type) – Reads the contents of a text file. Example: Get-Content -Path .\config.json
  • Set-Content (sc) – Writes or overwrites text to a file. Example: Set-Content -Path .\output.txt -Value "Hello"
  • Add-Content (ac) – Appends text to a file. Example: Add-Content -Path .\log.txt -Value "New entry"

System Information and Process Management

  • Get-Process (ps) – Lists running processes with CPU and memory usage. Example: Get-Process -Name chrome
  • Stop-Process (kill) – Terminates a process by name or ID. Example: Stop-Process -Name notepad
  • Get-Service – Lists Windows services and their status. Example: Get-Service -Name Spooler
  • Start-Service / Stop-Service – Starts or stops a service (requires admin). Example: Start-Service -Name Spooler
  • Get-ComputerInfo – Returns detailed system information (OS, RAM, BIOS). Example: Get-ComputerInfo | Select-Object OsName, TotalPhysicalMemory
  • Get-Date – Shows the current date and time. Example: Get-Date -Format "yyyy-MM-dd"

Working with Output and Help

  • Write-Output (echo) – Sends text to the pipeline. Example: Write-Output "Done"
  • Clear-Host (cls) – Clears the console screen.
  • Get-Help (help) – Displays help for a cmdlet. Example: Get-Help Get-Process -Examples
  • Get-Command – Finds all available cmdlets, functions, and aliases. Example: Get-Command -Verb Get
  • Where-Object (where) – Filters objects based on a condition. Example: Get-Process | Where-Object {$_.WorkingSet64 -gt 500MB}
  • Select-Object (select) – Chooses specific properties of an object. Example: Get-Process | Select-Object Name, CPU
  • Sort-Object (sort) – Sorts objects by a property. Example: Get-Service | Sort-Object Status
  • Measure-Object – Calculates statistics like sum, average, or count. Example: Get-ChildItem | Measure-Object -Property Length -Sum

How to Choose the Right Command

When you’re unsure which cmdlet to use, rely on the verb-noun pattern. If you need to retrieve something, start with Get. If you need to change something, try Set. If you need to create, use New. The Get-Command cmdlet with a wildcard can also help: Get-Command *process* lists all commands with “process” in the name. Additionally, Get-Help provides syntax, parameters, and examples for any cmdlet, so you can learn on the fly.

Common Problems and How to Avoid Them

  • Permission errors – Many commands (e.g., Stop-Service, Set-ItemProperty) require an elevated PowerShell session. Right-click PowerShell and select “Run as administrator.”
  • Execution policy blocks scripts – PowerShell may refuse to run scripts due to the execution policy. To see the current policy, run Get-ExecutionPolicy. To allow local scripts, run Set-ExecutionPolicy RemoteSigned (admin required).
  • Path issues – Use Test-Path to verify a path exists before using it. Example: Test-Path C:\Windows
  • Output formatting – If output is truncated, pipe to Format-List * to see all properties, or use Select-Object to choose specific ones.

PowerShell vs. CMD: Key Differences

CMD is the legacy command interpreter; it outputs plain text and has no object pipeline. PowerShell is far more powerful: it can manipulate objects, access .NET libraries, manage remote machines via WinRM, and handle structured data like JSON and CSV natively. For example, in CMD you’d need findstr to filter text; in PowerShell you simply use Where-Object on a property. If you’re starting fresh, PowerShell is the clear choice—it’s installed on every modern Windows system and is the basis for tools like Exchange and Azure management.

Safety and Best Practices

PowerShell gives you great power, so use it carefully. Always double-check the -Path and -Name parameters before running destructive commands like Remove-Item or Stop-Process. Consider using -WhatIf to preview what a command would do without actually executing it. For example, Remove-Item -Path .\temp -Recurse -WhatIf shows which items would be deleted. Also, avoid running scripts from untrusted sources; review the code first and understand the execution policy. Finally, when working with sensitive data, use secure strings and avoid hardcoding passwords in scripts.

Frequently Asked Questions

How do I list all files in a directory including subfolders?

Use Get-ChildItem -Path C:\MyFolder -Recurse. This returns all files and folders in the specified path and every subdirectory. Add -File to show only files, or -Directory to show only folders.

How do I find a command that does a specific task?

Use Get-Command *keyword*. For example, Get-Command *service* returns all cmdlets with “service” in the name. You can also use Get-Help to browse help topics.

What does the pipe symbol do in PowerShell?

The pipe (|) passes the output of one command as input to the next. For instance, Get-Process | Sort-Object CPU -Descending sends the process list to the sort command, which orders it by CPU usage. This chaining is the heart of PowerShell’s power.

How do I see all properties of an object?

Pipe the object to Format-List *. For example, Get-Item C:\Windows\system.ini | Format-List * shows every property (Name, Length, CreationTime, etc.) in a vertical list.

How do I run a PowerShell script?

Navigate to the script’s folder and run .\script.ps1. If you get an execution policy error, run Set-ExecutionPolicy RemoteSigned as administrator, then try again. Remember to use the dot-backslash prefix to tell PowerShell you’re running a local file.

How do I stop a process that is not responding?

Use Stop-Process -Name notepad or Stop-Process -Id 1234. To find the process ID first, use Get-Process | Where-Object {$_.Responding -eq $false} to list non-responding processes.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →