I'm having some issues with a powershell script that creates signatures for Microsoft Outlook. I'm not very familiar with powershell and are attempting to modify an existing script. The problem I have is the encoding in the txt-file for unformatted mails. I'm in Sweden, so it needs to be able to use swedish characters (åäö). The txt-file that the script outputs do contain proper åäö, but when the signature is opened in Outlook, those characters becomes problematic, ä is shown as ä, ö as ö and so on. After a little bit of googling, it seems that Outlook use Windows-1252, but I can't get powershell to output to that encoding.
This is the script as it looks right now;
$stream = [System.IO.StreamWriter] "$FolderLocation\test.txt"
$stream.WriteLine("--- OBS TEST ---")
$stream.WriteLine("Med vänlig hälsning")
$stream.WriteLine(""+$strName+"")
$stream.WriteLine(""+$strTitle+"")
$stream.WriteLine("")
$stream.WriteLine(""+$strCompany+"")
$stream.WriteLine(""+$strStreet+"")
$stream.WriteLine(""+$strPostCode+" "+$strCity+"")
$stream.WriteLine("")
if($strPhone){$stream.WriteLine("Telefon: " + $strPhone+"")}
if($strMobile){$stream.WriteLine("Mobil: " + $strMobile+"")}
$stream.WriteLine("")
$stream.WriteLine("E-post: "+ $strEmail+"")
$stream.WriteLine("Hemsida: "+ $strWebsite+"")
$stream.close()
The file that this outputs looks perfectly ok when opened in notepad.
I tried this to re-encode the output file into various encoding, but no success;
get-content -path $FolderLocation\test.txt | out-file -filePath $FolderLocation\$strName.txt -encoding UTF8
Any tips on how to solve this?