Ian's Software for Mere Mortals

Youngjune or Ian's blog about Connectivity

Changing text encodings of output files redirected from PowerShell.

Changing text encodings of output files redirected from PowerShell.

  • Comments 1

I created a logman setting file as follows:
typeperf -q | where { $_ -like "\Phy*" } | foreach { '"' + $_.Trim() + '"' } > counter.txt

But, logman raised an error reading “Invalid counter path” when I tried to update a counter data collection with the settng file, counter.txt. That’s right. Logman requires the ANSI encoding for its setting file, while the output redirection that PowerShell created Unicode files for that redirection.

Then, How to create a output text file with different encodings?

typeperf -q | where { $_ -like "\Phy*" } | foreach { '"' + $_.Trim() + '"' } | output –encoding ASCII