Forum Discussion
Anna-Maria Kähkönen
Jul 19, 2017Iron Contributor
What is wrong with this?
Hi guys, Can someone tell me what is wrong with attached script. When I change my own tenant settings and run this, I got below error. I have gone it trought a dosens of times and I just can't se...
Simon Wåhlin
Jul 19, 2017MVP
Hi Anna-Maria,
You have a problem with encoding where a few dashes (-) are replaced with the text –. This usually happens when copying and pasting text between different programs.
Try using the following code to "fix" the script (UTF8 and default might need other values but I assume these are the ones needed):
$InPath = 'C:\temp\ExportVideoChannelsInfoToCSV.ps1'
$OutPath = 'C:\temp\ExportVideoChannelsInfoToCSV_newencoding.ps1'
Get-Content -Path $InPath -Encoding UTF8 | Out-File -FilePath $OutPath -Encoding default
Or you can use a text editor (like Visual Studio Code) to reopen the file with different encodings until it looks allright.
Anna-Maria Kähkönen
Jul 20, 2017Iron Contributor
Thank you so much for explaining what was wrong. It was killing me not knowing.