Smarts: Does Smarts support Powershell?
search cancel

Smarts: Does Smarts support Powershell?

book

Article ID: 306615

calendar_today

Updated On:

Products

VMware Smart Assurance

Issue/Introduction

Symptoms:


Does Smarts support Powershell?

Output generated from ITOps commands within Windows PowerShell is unusable

Environment

VMware Smart Assurance - SMARTS
VMware Smart Assurance - NCM

Cause

PowerShell automatically converts all piped and redirected command output into the UTF-16LE encoding scheme format. (UTF-16 refers to the ISO standard 16-bit Unicode Transformation Format which maps each character to a sequence of 16-bit words.). ITOps software expects the UTF-8 format for input files, so if the output of one ITOps application is redirected to file (for later consumption by another ITOps application) then the result is that the ITOps application will fail to parse the file.

Resolution

PowerShell expects the application to behave in a 'cmd.exe'-compatible way, so it is important to leave all SM_ENCODING_xxxx variables unset. The defaults already auto-initialize to 'cmd.exe'-compatible values. Since PowerShell itself post-processes output from 'cmd.exe' style into UTF-16LE, the only way to get it back into a form that ITOps software accepts (UTF-8) is to further post-process it with a transcoder utility. PowerShell provides 'Out-File' for this purpose.

sm_server "--version" > version.out
sm_server "--version" " Out-File -Encoding utf8 version.out

The first example will result in the 'version.out' file encoded as UTF-16LE. This is fine if you intend to view it with a UTF-16LE-capable text editor. If the output is to be parsed by another ITOps application, then the second (piped) form must be used to result in the 'version.out' file encoded as UTF-8.