Functions/Data/Out-FileUTF8NoBOM.ps1
Function Out-FileUTF8NoBOM { [CmdletBinding()] Param ( # FilePath [Parameter(Mandatory=$true)] [String] $FilePath, # Object to Input [Parameter(Mandatory=$false,ValueFromPipeLine=$true)] [System.Management.Automation.PSObject] $InputObject ) Begin { # Define File Encoding $Encoding = [System.Text.UTF8Encoding]::new($False) # Create String Array Object to contain piped input $StringArr = [System.Collections.ArrayList]::new() } Process { # Append Piped Input to String Array Object $NULL = $StringArr.Add($InputObject) } End { # Output File with Input and Encoding to Path [System.IO.File]::WriteAllLines($FilePath, $StringArr, $Encoding) } } |