PowerShell (pwsh) is fundamentally different from traditional command-line shells like Bash or Zsh.
While other shells primarily deal with streams of text, PowerShell is built around objects — a core design that enhances scripting efficiency, data manipulation, and overall readability.
This object-oriented nature makes PowerShell one of the most powerful tools for system administration, data processing, and cross-platform automation.
🧠 Core Concept: Objects, Not Text
In traditional shells, command output is plain text. To extract specific data, you rely on utilities like grep, awk, or sed, often combined with regular expressions.
This approach is fragile — if the output format changes, your script can break.
PowerShell cmdlets, on the other hand, output rich, structured objects.
Each object has properties (data) and methods (actions) that you can access directly — no parsing needed.
🔍 Example: Getting Process Information
In Bash:
ps aux | grep chromeThis returns plain text, requiring manual parsing to extract details like PID or CPU usage.
In PowerShell:
Get-Process -Name chromeThis returns one or more [System.Diagnostics.Process] objects, each with accessible properties like:
IdProcessNameCPUWorkingSet
You can view all available members:
Get-Process | Get-Member⚙️ Working with Object-Oriented Cmdlets
PowerShell’s pipeline allows structured objects to flow from one cmdlet to another, preserving data integrity and type information.
Let’s look at key cmdlets that make object manipulation efficient and intuitive.
🎯 Select-Object — Selecting Specific Properties
Instead of parsing text columns, you can pick exact properties:
Get-Process | Select-Object -Property ProcessName, Id, WorkingSetThis retrieves all running processes and returns only the selected fields.
Result: faster, cleaner, and less data-heavy pipelines.
🧩 Where-Object — Filtering Objects by Properties
Filter objects based on property values (no regex or text parsing required):
Get-Service | Where-Object -Property Status -EQ 'Running'This returns only running services — simple and reliable.
⚡ Sort-Object — Sorting by Properties
Sort any collection of objects using their properties:
Get-Process | Sort-Object -Property CPU -Descending |
Select-Object -First 5 ProcessName, CPUDisplays the top five CPU-consuming processes, sorted efficiently in memory.
📊 Group-Object — Grouping by Common Properties
Aggregate or categorize data based on shared properties:
Get-ChildItem -Path C:\Windows\System32 |
Group-Object -Property Extension -NoElement |
Sort-Object -Property Count -DescendingGroups files by extension and sorts by count — a quick way to analyze directories.
🔁 ForEach-Object — Iterating Over Objects
Perform actions on each object in the pipeline:
Get-Service | Where-Object Status -EQ 'Stopped' |
ForEach-Object { Start-Service -InputObject $_ }This starts all stopped services.
The automatic variable $_ represents the current pipeline object.
🔗 Piping Objects — Preserving Data Integrity
Each cmdlet passes objects to the next stage, not plain text — ensuring data consistency throughout the pipeline.
Get-ADUser -Filter * -Properties Department |
Group-Object -Property Department |
Select-Object -Property Name, CountIn this Active Directory example, users are grouped by department, and results are neatly summarized — no parsing required.
🚀 Performance & Efficiency
PowerShell 7 (pwsh) significantly improved performance for core cmdlets such as:
Group-ObjectSort-ObjectSelect-ObjectWhere-ObjectMeasure-Object
These improvements come from optimized in-memory pipelines and reduced serialization overhead.
Example: Grouping and Sorting Efficiently
Measure-Command {
Get-Process |
Group-Object -Property ProcessName |
Sort-Object Count -Descending
}This runs 2–5x faster in PowerShell 7+ than in Windows PowerShell 5.1, thanks to .NET Core’s streamlined object handling.
📦 Files, Services, and Processes as Objects
Every item in PowerShell is an object.
You can inspect files, processes, or services using consistent patterns:
Get-ChildItem ~/Documents | Select-Object Name, Length, LastWriteTimeOutput:
| Name | Length | LastWriteTime |
|---|---|---|
| report.docx | 48200 | 2025-10-26 17:42:18 |
| notes.txt | 1589 | 2025-10-25 21:09:07 |
Filter by property:
Get-ChildItem ~/Documents | Where-Object Length -gt 10000🧩 Creating and Using Custom Objects
You can easily create your own structured data:
$server = [PSCustomObject]@{
Name = "WebServer01"
IP = "192.168.10.15"
Online = $true
}
$serverOutput: Name IP Online
WebServer01 192.168.10.15 True
And of course, these custom objects can flow through the pipeline like any other:
$servers | Where-Object Online -eq $true | Select-Object Name, IP🧮 Converting Objects (JSON, CSV, YAML)
PowerShell can convert objects between formats without losing structure:
# To JSON
Get-Process pwsh | ConvertTo-Json | Out-File processes.json
# From JSON
$json = Get-Content processes.json | ConvertFrom-Json
$json[0].ProcessNameFor YAML (with module):
Install-Module powershell-yaml -Scope CurrentUser
$yaml = Get-Process pwsh | ConvertTo-Yaml🔍 Why pwsh Stands Apart from Traditional Shells
| Feature | Description |
|---|---|
| Structured Data | Eliminates fragile text parsing — work directly with object properties. |
| Discoverability | Get-Member shows all properties and methods of any object. |
| Consistency | Cmdlets follow Verb-Noun naming (e.g., Get-Process, Set-Service). |
| .NET Integration | Access .NET classes and methods directly in PowerShell. |
| Robust Error Handling | Use try/catch/finally and -ErrorAction for fine-grained control. |
Example:
try {
Get-Service -Name "InvalidService" -ErrorAction Stop
} catch {
Write-Host "Service not found."
}⚡ Performance Summary
| Feature | Improvement in pwsh 7+ |
|---|---|
| Group-Object | Optimized hash-based grouping (~2–3× faster) |
| Sort-Object | Efficient memory sorting for large datasets |
| ForEach-Object -Parallel | Multi-threaded execution |
| Pipeline operations | Reduced serialization overhead |
| JSON conversion | Up to 4× faster ConvertTo-Json |
✅ Conclusion
PowerShell’s object-oriented architecture revolutionizes how you automate and interact with systems:
- Commands produce structured, typed data
- Pipelines maintain data integrity
- Cmdlets are optimized for performance
- Error handling and discoverability are built in
Whether you’re managing a Hugo site, automating Active Directory, or scripting in WSL — mastering PowerShell’s object features will dramatically boost your productivity, reliability, and speed.