Files, encoding, and side effects
Encoding
- Windows PowerShell 5.1 and PowerShell 6+ have different defaults. Windows PowerShell cmdlets use several inconsistent defaults; PowerShell 6+ commonly writes UTF-8 without a BOM.
- Defaults can vary by cmdlet, operation, append behavior, and BOM detection. Specify an encoding when interoperability matters instead of assuming one default applies everywhere.
Side effects
[CmdletBinding(SupportsShouldProcess)]adds-WhatIfand-Confirmsupport to a function, but does not guard effects by itself.- Run each protected state-changing operation only when
$PSCmdlet.ShouldProcess(...)returns$true.