Free tech learning for everyone, from basics to pro

ScriptingProgramming and Application SecurityBeginner

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.

Text vs objectsBash pipelinePasses plain textParse with grep, awkColumn positions matterFragile if output changesPowerShell pipelinePasses .NET objectsPick properties by nameSort, filter, export easilyStable across versions
Figure 1. The key difference: PowerShell passes structured objects along the pipeline, not lines of text.

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

A typical pipelineGetGet-ServiceFilterWhere-ObjectShapeSelect-ObjectOrderSort-ObjectOutputExport-Csv
Figure 2. Most PowerShell one-liners get objects, filter them, choose properties, sort and then output.
# 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 habitPowerShell equivalent
ls, cat, cpGet-ChildItem, Get-Content, Copy-Item (aliases work too)
grepSelect-String or Where-Object
$? or exit code$?, $LASTEXITCODE, try/catch
echoWrite-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?
It shows the properties and methods of the objects in the pipeline, so you know what you can filter, sort or select on.
What does $_ mean inside Where-Object?
The current object passing through the pipeline.
Is the execution policy a security control against attackers?
No. It prevents accidental running of scripts but can be bypassed easily; real protection comes from application control, least privilege and signing.

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.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

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.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.