Results for “PowerShell”
Small, practical examples. Search by task or narrow things down below.
Split text on a simple delimiter
PowerShell: The split operator uses a regular expression; this delimiter has no special regex meaning.
PowerShell✓ Tested
Test whether an array contains a value
PowerShell: The contains operator compares complete items rather than matching substrings.
PowerShell✓ Tested
Transform each pipeline value
PowerShell: Transform each pipeline value using PowerShell 7.
PowerShell✓ Tested
Trim whitespace around a string
PowerShell: The Trim method removes surrounding whitespace while preserving the middle of the string.
PowerShell✓ Tested
Use a counted loop
PowerShell: Use a counted loop using PowerShell 7.
PowerShell✓ Tested
Use a fallback for a missing hashtable entry
PowerShell: Test the key explicitly so legitimate false or zero values are preserved.
PowerShell✓ Tested
Use a literal value in a regular expression
PowerShell: Regex.Escape prevents a literal dot or other metacharacter from changing the match.
PowerShell✓ Tested
Write a multiline string without expanding variables
PowerShell: A single-quoted here-string preserves dollar signs literally.
PowerShell✓ Tested
Write object records to a CSV file
PowerShell: Export-Csv uses property names as headers and quotes values when needed.
PowerShell✓ Tested
Build a portable file path
Combine directory and filename using the platform separator.
Join-Path✓ Tested
Choose an action with switch
Map a small command value to a result.
switch✓ Tested
Count items by group
Group repeated values and report each count.
Group-Object✓ Tested