I’m trying to run a script that analyzes some log files, and the logs are in Dansih. I can run the script inline (as in entering the lines one by one to the terminal) without a problem, but when I try to run the script as a file (.\script.ps1 ARGS), the encoding breaks and dose not process the danish charachters. I have tried many thing Including
$OutputEncoding = [System.Text.Encoding]::UTF8 $PSDefaultParameterValues = @{ '*:Encoding' = 'utf8' }
and have appended
-Encoding UTF8every where I can, but still no result, and the strange part is if I run the script line by line there is no problem.
for example
$targets = ‘Kørselsdato’, ‘Tidspunkt’, ‘JobId’, ‘Antal læste på tabellen AFSENDNEMSMS’, ‘Køretid i minutter’
$targets | Out-File “.res.txt”
this will work line by line but not when I run it as a script file
result of runing as a script :
Kørselsdato
Tidspunkt
JobId
Antal læste på tabellen AFSENDNEMSMS
Køretid i minutter
result of runing line by line :
Kørselsdato
Tidspunkt
JobId
Antal læste på tabellen AFSENDNEMSMS
Køretid i minutter