REST api ./iem get sites format issue

In the BIGFIX 9.5 we face the issue with generate the xml with code below.

./iem login --server=$server_ip --user=$login --password=$pass
./iem get sites

The result is xml i full “spaces” between each char. Any ideas ??

Would you be able to share a screenshot or similar to help with context? Have you attempted to redirect the output to a file to then open to check/validate the characters in question?

I have tried many ways to save the output. out-file, export-clixml etc. the results are the same. Please check the output from the console.

In bigfix 9.1 or 9.2 we do not have any issues with:

/iem login --server=$server_ip --user=$login --password=$pass
./iem get sites

The issue is in 9.5 as I said.

I have tried with my on Japanese Windows.
When I run iem.exe from command window, the result looks good, both on command window and redirected file. (No “space” in XML).
But when I run iem.exe from PowerShell, I got the same result as yours.

When redirected the output from PowerShell to file, the file begins like (in hex)

FF FE 3C 00 00 00 3F 00 00 00 78 00 00 00

The first two bytes of FF FE are Byte Order Mark indicating file is in UTF-16LE, but contents after that looks like encoded to UTF16 twice. It looks like iem.exe produces output in UTF-16LE, but PowerShell somehow think iem.exe output is in Local Encoding (Shift_JIS in my case) and transcoded to UTF-16LE again.

I found a useful blog post at (blog is in Japanese).
Based on this blog post, following will tell PowerShell that output from iem.exe is in UTF-16LE to avoid double encoding of single byte characters.

$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = "C:\Program Files (x86)\BigFix Enterprise\BES Server\IEM CLI\iem.exe"
$psi.Arguments = "get sites"
$psi.StandardOutputEncoding = [Text.Encoding]::Unicode
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$p = [System.Diagnostics.Process]::Start($psi)
$s = $p.StandardOutput.ReadToEnd()
1 Like

Thank you feedback. I will test the solution and let you know about the progress.

Yes Same as mentioned by Marius Borys ,I am observing the issue with the IEM 9.5 .