PowerShell 7 & Sysadmin Master Cheat Sheet: Pipelines, Cmdlets & Automation
The ultimate modern PowerShell 7 guide for Windows and cross-platform sysadmins: object pipelines, high-speed filtering, file hashes, network diagnostics, and administrative one-liners.
1. The Object Pipeline & Filtering Magic
Get-Process | Sort-Object WorkingSet64 -Descending | Select-Object -First 10 -Property Name, @{Name="RAM (MB)"; Expression={[math]::round($_.WorkingSet64 / 1MB, 2)}}Sorts processes by physical memory and calculates human-readable megabytes.
Get-Service | Where-Object { $_.StartType -eq "Automatic" -and $_.Status -ne "Running" }Identifies critical background services that failed to boot on startup.
2. File Management & Checksum Verification
Get-ChildItem -Path C:\ -Recurse -File -ErrorAction SilentlyContinue | Where-Object Length -gt 500MB | Select-Object FullName, @{N="Size (GB)"; E={[math]::round($_.Length / 1GB, 2)}}Searches drives for storage-consuming files while suppressing permission errors.
Get-FileHash -Path .\installer.exe -Algorithm SHA256 | Format-ListCalculates the official SHA-256 hash to verify binary integrity.
Select-String -Path .\logs\*.log -Pattern "FATAL|EXCEPTION" -Context 2,2Searches log files with regex matching and outputs 2 lines of before/after context.
3. Network & Port Diagnostics (Test-NetConnection)
Test-NetConnection -ComputerName "api.github.com" -Port 443Performs full TCP handshake test and reports TcpTestSucceeded: True/False.
Test-NetConnection -ComputerName "1.1.1.1" -TraceRouteMaps the IP routing hops and network latency across internet gateways.
Resolve-DnsName -Name "mayonlinetools.com" -Type AFetches IPv4 A records, TTL values, and nameserver responses.
4. Essential Administrator One-Liners
Clear-DnsClientCacheImmediately purges cached DNS records without restarting networking.
$data = Invoke-RestMethod -Uri "https://api.github.com/zen"
Write-Host "Zen Quote: $data"Calls REST endpoints and automatically deserializes JSON into native PowerShell objects.
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -ForceAllows executing local automation scripts while blocking unsigned internet downloads.
Related Free Online Tools
Put these techniques into practice immediately with our privacy-first browser utilities:
Verify cryptographic checksums computed with Get-FileHash.
Decode and inspect Base64 strings used in PowerShell -EncodedCommand.
Test and debug regex patterns for Select-String and -match operators.