I have a series of scripts that out use “out-file” cmdlet to output a variable to a text file. After an upgrade to PS 7.2.1, I started getting a series of strange characters in the output of the text file. After a little investigation, these appear to be ANSI Escape Codes as far as I can tell.
Note: User information has been obscured with asterisks (*****)
you see the recurring patterns of e[32;1m and e[0m
This does NOT occur in earlier versions of PS.
At first I thought it might be an encoding issue, but I’ve tried every available encoding scheme (out-file -encoding ASCII/UTF8/Unicode/ et al) with the same results. Any ideas here?
I just ran get-process | Out-file on a test Windows 11 box that’s not on the domain with the same results…I’m seeing the ansi escape codes as well in the header. Displays properly in the console…just the associated output text file that has the goofy characters.
Also just fired up a brand new windows 10 VM that’s never been used / Not on domain, downloaded PS 7.2.1 x64 from Github, and ran get-process | Out-file C:\file.txt
Console shows correctly. The output text file has the issues.
Headers show the escape characters:
e[32;1m NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessNamee[0m
e[32;1m ------ ----- ----- ------ – – -----------e[0m