PowerShell StringBuilder Pattern for Large Text Generation
String concatenation with += in a loop is one of PowerShell’s worst performance patterns. StringBuilder eliminates the O(n squared) overhead for scripts generating large text
Commands Tips
String concatenation with += in a loop is one of PowerShell’s worst performance patterns. StringBuilder eliminates the O(n squared) overhead for scripts generating large text
Align text output in PowerShell reports using PadLeft, PadRight, and format strings. Create readable console tables without Format-Table.
ConvertTo-Json silently truncates deep nested objects. Learn how to set the correct -Depth value and why the default of 2 causes data loss.
Tool output is often unstructured text. Learn to parse ipconfig, netstat, and other command output into PowerShell objects using regex and split.
Common regex patterns for PowerShell: validate emails, extract IP addresses, match URLs, and detect dates. Copy-paste-ready for your scripts.
Named capture groups make regex results readable. Learn to define (?
PowerShell has three main string comparison operators. Learn when to use -eq for exact matches, -like for wildcards, and -match for regex.
Write-Host and Write-Output look the same but behave very differently. Learn why Write-Host breaks pipelines and when each is the right choice.
Here-strings are perfect for multiline text blocks in PowerShell scripts. Learn single-quoted and double-quoted here-strings with template examples.
Format numbers as currency or percentages and dates as any string with PowerShell’s -f operator and ToString() method examples.