PowerShell Examples

PowerShellOct 23, 2026

Render an Aligned Plain-Text Table in PowerShell

Renders objects as a column-aligned plain-text table sized to the widest cell, ready for console or log output.

formattingtableconsole
000
PowerShellOct 23, 2026

Base64 Encode and Decode UTF-8 Text in PowerShell

Encodes UTF-8 text to Base64 and decodes it back, catching malformed input and rethrowing with a clearer message.

textencodingbase64
000
PowerShellOct 23, 2026

PowerShell Input Validation with Field-Level Errors

Checks record fields and returns a validity flag plus per-field error messages instead of throwing on the first problem.

errorsvalidationforms
000
PowerShellOct 23, 2026

Build and Parse Query Strings with System.Uri in PowerShell

Encodes a hashtable into a percent-escaped query string and parses one back into a hashtable of decoded keys and values.

query-stringurlencoding
000
PowerShellOct 23, 2026

Parse JSON in PowerShell with Clear Error Messages

Wraps ConvertFrom-Json so empty input and malformed documents raise an error naming the offending line and position.

parsingerrorsjson
000
PowerShellOct 23, 2026

PowerShell HTTP GET JSON with a Hard Timeout

Performs an HTTP GET with a hard timeout, parses the JSON body, and raises a clear error on failure or empty content.

httpjsontimeout
000
PowerShellOct 23, 2026

PowerShell Bounded Worker Pool with ForEach-Object Parallel

Runs a script block over many items with a fixed number of parallel workers and returns separate result and error lists.

concurrencyworker-poolparallel
000
PowerShellOct 23, 2026

Load and Validate Environment Config in PowerShell

Reads environment variables through a schema of defaults, required flags and validators, failing fast on bad config.

environmentconfigurationvalidation
000
PowerShellOct 23, 2026

PowerShell Token Bucket Rate Limiter Class

Limits work to an average rate while allowing bursts up to a bucket capacity with a monotonic refill calculation.

rate-limitthrottlingclass
000
PowerShellOct 23, 2026

PowerShell LRU Cache Class with Bounded Capacity

Provides a fixed-capacity cache that evicts the least recently used entry and refreshes recency on every read.

lrucacheclass
000
PowerShellOct 23, 2026

PowerShell Multi-Key Stable Sort with Nulls Last

Sorts records by one or more properties with a stable sort and pushes rows whose first sort key is null to the end.

nullssortingrecords
000
PowerShellOct 23, 2026

Split a PowerShell Collection into Fixed-Size Batches

Splits any collection into arrays of a fixed size, keeping the final short batch, for batched API or database calls.

batchingpipelinecollections
000
PowerShellOct 23, 2026

Stream a Text File Line by Line in PowerShell

Enumerates a text file lazily with File.ReadLines so very large files never have to be held in memory at once.

streaminglinesfile-io
000
PowerShellOct 23, 2026

PowerShell Deep Clone and Recursive Merge of Hashtables

Creates a deep copy of a hashtable tree via JSON and recursively overlays another tree without mutating either source.

mergeclonehashtable
000
PowerShellOct 23, 2026

PowerShell Retry with Exponential Backoff and Jitter

Runs a script block with capped exponential backoff and jitter, retrying transient failures up to a fixed attempt limit.

resiliencebackoffretry
000