PowerShell basics: cmdlets, objects and the pipeline
In short: PowerShell is a shell and scripting language that passes objects rather than text along its pipeline. Learn the verb-noun cmdlet names, use Get-Help and Get-Member to explore, and you can filter, sort and export almost anything in Windows.
What PowerShell is
PowerShell is Microsoft's shell and scripting language. Two editions exist: Windows PowerShell 5.1, built into Windows, and PowerShell 7, the cross-platform version that runs on Windows, Linux and macOS and is installed separately. Most commands work in both, and new scripts should target PowerShell 7 where possible.
Commands are called cmdlets and follow a Verb-Noun pattern: Get-Service, Restart-Service, Test-NetConnection. Once you know the common verbs (Get, Set, New, Remove, Start, Stop, Test) you can often guess a command's name.
Exploring with help
Three commands teach you the rest of PowerShell:
Get-Command -Noun *Net* # find commands by name
Get-Help Test-NetConnection -Examples
Get-Service | Get-Member # show the properties and methods of the objects
Get-Member is the important one. Because the pipeline carries objects, you need to know what properties each object has. A service object has Name, Status and StartType, so you can filter on them directly instead of cutting text.
The pipeline in action
# Automatic services that are not running, saved to CSV
Get-Service |
Where-Object { $_.StartType -eq 'Automatic' -and $_.Status -ne 'Running' } |
Select-Object Name, DisplayName, Status |
Sort-Object Name |
Export-Csv -Path .\stopped-services.csv -NoTypeInformation
Inside a script block, $_ (or $PSItem) means the current object. Comparison operators are words, not symbols: -eq, -ne, -gt, -lt, -like and -match.
Variables, loops and your first script
$servers = @('fs01', 'dc01', 'print01')
foreach ($s in $servers) {
$ok = Test-Connection -ComputerName $s -Count 1 -Quiet
if ($ok) { Write-Output "$s reachable" }
else { Write-Warning "$s not responding" }
}
Save this as Check-Servers.ps1. Windows uses an execution policy to control which scripts may run. On managed devices it is usually set by Group Policy; on your own machine Set-ExecutionPolicy -Scope CurrentUser RemoteSigned allows local scripts while requiring downloaded ones to be signed. The execution policy is a safety catch against accidents, not a security boundary, so never treat it as protection against malicious users.
At work you will meet PowerShell constantly if you support Windows servers, Microsoft 365 or Hyper-V. Many admin tasks that take dozens of clicks in a console, such as listing every disabled account or every stopped service on twenty servers, become a single pipeline. In exams and interviews, expect questions about the pipeline, the Verb-Noun naming pattern and the difference between Windows PowerShell 5.1 and PowerShell 7. If you already know Bash, the table below maps familiar habits to their PowerShell equivalents.
| Bash habit | PowerShell equivalent |
|---|---|
ls, cat, cp | Get-ChildItem, Get-Content, Copy-Item (aliases work too) |
grep | Select-String or Where-Object |
$? or exit code | $?, $LASTEXITCODE, try/catch |
echo | Write-Output |
Tip: aliases such as ls and ? are handy at the prompt, but write full cmdlet names in scripts so others can read them.
Practice
Why is Get-Member so useful?
What does $_ mean inside Where-Object?
Is the execution policy a security control against attackers?
Key takeaways
- Cmdlets follow a Verb-Noun naming pattern.
- The pipeline passes objects; filter by property, not by text.
- Get-Command, Get-Help and Get-Member let you discover everything else.
- Use full cmdlet names in scripts and aliases only at the prompt.
- Execution policy prevents accidents but is not a security boundary.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.