The snippet library.
Small, practical examples. Search by task or narrow things down below.
Convert between hexadecimal text and bytes
PowerShell: Use the .NET hexadecimal helpers instead of parsing byte pairs manually.
PowerShell✓ Tested
Encode and decode UTF-8 text with Base64
PowerShell: Convert the string to bytes explicitly before Base64 encoding.
PowerShell✓ Tested
Escape a single URL parameter value
PowerShell: EscapeDataString encodes one value without treating it as a complete URL.
PowerShell✓ Tested
Escape plain text before placing it in HTML
PowerShell: HtmlEncode converts HTML delimiters to entities in ordinary text contexts.
PowerShell✓ Tested
Handle a malformed JSON document
PowerShell: ConvertFrom-Json reports a terminating conversion error under the selected error preference.
PowerShell✓ Tested
Read a tab-separated table
PowerShell: ConvertFrom-Csv accepts an explicit delimiter instead of requiring comma-separated input.
PowerShell✓ Tested
Read a value from a trusted XML document
PowerShell: The XML adapter exposes a small document’s elements and attributes through named properties.
PowerShell✓ Tested
Read JSON into a hashtable
PowerShell: AsHashtable produces dictionary-style results for keys that are data rather than fixed property names.
PowerShell✓ Tested
Serialize nested objects with an explicit depth
PowerShell: Select a sufficient depth so nested data is retained instead of converted into a descriptive string.
PowerShell✓ Tested
Write object records to a CSV file
PowerShell: Export-Csv uses property names as headers and quotes values when needed.
PowerShell✓ Tested