Is it possible to redirect output to a file using the redirection operator without writing a byte-order mark in Powershell?
问题 Is there any way to omit the byte-order mark when redirecting the output stream to a file? For example, if I want to take the contents of an XML file and replace a string with a new value, I need to do create a new encoding and write the new output to a file like the following which is rather ham-handed: $newContent = ( Get-Content .\settings.xml ) -replace 'expression', 'newvalue' $UTF8NoBom = New-Object System.Text.UTF8Encoding( $false ) [System.IO.File]::WriteAllText( '.\settings.xml',