Share via


Set-Content cmdlet: paramater cannot be found that matches 'Encoding'

Question

Wednesday, August 8, 2018 7:00 PM

Hello,

I am trying to execute the following command on a server in PowerShell v4 but receive an error stating that a parameter cannot be found that matches parameter name 'Encoding'. I am using this command in a script to change the encoding of the CSV file to UTF-8. 

Get-Content -Path "X:\File.csv" | Set-Content -Path "X:\File.csv" -Encoding UTF8 -Force

The command runs fine on my local machine with PowerShell v5. The 'Encoding' parameter appears to be available in Get-Help Set-Content when I run it on the server. 

All replies (3)

Wednesday, August 8, 2018 8:28 PM

Set-Content for PS 5.1 and earlier does not support encoding.

Use the following:

(Get-Content X:\File.csv)| Out-File X:\File.csv -Encoding UTF8

\(ツ)_/


Wednesday, August 8, 2018 9:29 PM

Actually encoding does work.  On W10 I had to reboot to get it to show.  There are still issues with PS on 10 and I cannot figure out why.

W7, WS2009R2 and all later servers allow for encoding for system drives.  W10 seems to forget.

\(ツ)_/


Thursday, August 9, 2018 1:34 AM

The -Encoding parameter works on my Windows 10, but some things are strange, especially after I was upgraded to version 1803. I no longer can edit TechNet Wiki articles in Edge, and strange things happen when I edit them in IE 11. Engineering is looking into it.

Richard Mueller - MVP Enterprise Mobility (Identity and Access)

All of us are looking into this.  There are many strange things in Windows these days.

Many things are likely do to security blocks implemented.  A lot of COM seems to no longer work from scripts.  Since 1803 no videos from some sites will load in  IE or Edge.  The pages act like no video support is available and yet most other sites work correctly.

We wait for the next patch release for relief.

\(ツ)_/