I want to set the encoding of a file to ANSI using the parameter -Encoding of the Set-Content cmdlet, I tried this one but it didn\'t work:
-Encoding
Set-Content
<
I use the .NET WriteAllText function for that:
.NET
WriteAllText
[IO.File]::WriteAllText($filePath, (Get-Content $filePath))
Ensure the default encoding reflects your desired output using:
[System.Text.Encoding]::Default
Otherwise, add the enum with the desired encoding as the third parameter.