VMware Cloud Community
IKirill
Enthusiast
Enthusiast

Output in Invoke-VMScript unreadable

Hi!

In my Powercli scripts, I use the Invoke-VMScript cmdlet. On non-English operating systems, the command output becomes unreadable. For example: ���

I know that in this example should be Cyrillic.

How can I get a normal output ?

I suspect I have somewhere to enable UTF-8 encoding.

0 Kudos
24 Replies
LucD
Leadership
Leadership

Do you launch that from a Windows or a Linux platform?
Which Linux distro are you using?
On the Linux box do you have the locales package installed?

Check on the Linux box with the locale command what settings are in use.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

Have a look at (and replace en_US with the correct name) the 2nd answer in https://unix.stackexchange.com/questions/303712/how-can-i-enable-utf-8-support-in-the-linux-console


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
IKirill
Enthusiast
Enthusiast

Hi LuCD!

I use Windows Server 2008 R2

0 Kudos
DCasota
Expert
Expert

For the scriptblock did you save the Cyrillic codepage ? Depending on your os the code page is builtin available or not.

$scriptBlock="Your Cyrillic text"

$enc = [Console]::OutputEncoding
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("cp866")
& $scriptBlock
[Console]::OutputEncoding = $enc

You find some additional os release related culprit information at https://stackoverflow.com/questions/49476326/displaying-unicode-in-powershell

0 Kudos
IKirill
Enthusiast
Enthusiast

My script text very simple, but not working:

-Scripttext "net use Y: \\10.2.0.254\D /user:Administrator Mypass /persistent:no

mkdir C:\rollup

copy Y\* C:\rollup"

the problem is that net use does not work. I see only unreadable output, like

ScriptOutput

-----------------------------------------------------------------------------------------------------------------------|  ���।�������� ������: &

.

-----------------------------------------------------------------------------------------------------------------------

This output is Cyrillic

0 Kudos
DCasota
Expert
Expert

On the Windows 2008 R2 cmd what return results from wmic os get locale, oslanguage, codeset ?

0 Kudos
IKirill
Enthusiast
Enthusiast

LucD

I use Windows Server!

DCasota

Codeset    Locale   OSLanguage

1251         0419      1049    

0 Kudos
DCasota
Expert
Expert

Is the return result from the guest OS VM or from the Invoke-VMScript side ?

0 Kudos
DCasota
Expert
Expert

You may give a try to Powershell and Cyrillic in the console (updated) . To work on a Linux box (as assumed from @LucD !) might avoid culprit of Powershell ISE visualization of Cyrillic on a Windows box.

However, it has nothing to do with the net use error you mentioned before. Check connectivity, IP, share with user privileges set.

0 Kudos
LucD
Leadership
Leadership

Oops, I misread that.

Is the language on the station where you run Invoke-VMScript English or also Russian?

Did you install the Russian version of Windows 2008 R2, or did you add a language pack afterwards?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
IKirill
Enthusiast
Enthusiast

One of our customers uses the Russian version of WIndows Server 2008 r2 as a guest system.

The system is initially deployed Russian, without installing language packs.

PS ISE is also launched on the Russian version of Windows Server 2012 r2. There are actually two problems.

The first - does not work out NET USE, which has to connect a network disk.

The second is an error that I can't read.

Various variants of language encodings have not yet yielded a positive result.

0 Kudos
LucD
Leadership
Leadership

Do I understand that correctly, that the NET USE doesn't work?
Only from a PS prompt?

Only remote? Or local and remote (via Invoke-VMScript)?
Or also from a CMD prompt?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
IKirill
Enthusiast
Enthusiast

NET USE only works locally via CMD. That is I connect to problem WS2008R2 and through CMD without problems I connect a network disk. When I try to do the same via Invoke-VMScript, the network drive does not connect. Rather strange.

$backVMS = get-datacenter 02 | get-vm | `

           ? {$_.Name -like "*backup*" -and $_.Guest.OSFullName -match '2008 R2'} | `

           select name -ExpandProperty name

Write-Host "VM TO UPDATES $backVMs" -ForegroundColor Yellow

foreach ($backVM in $backVMS) {

Write-Host "START WORK -Work WITH $backVM" -ForegroundColor Green

Invoke-VMScript -VM $backVM -GuestUser adm `

                            -GuestPassword Pass `

                            -ScriptType bat `

                            -Scripttext "net use Y: \\10.2.0.254\D /user:Administrator Pass /persistent:no

                                         mkdir C:\rollup

                                         copy Y\* C:\rollup

                                         " -ErrorAction SilentlyContinue

Invoke-VMScript -VM $backVM -GuestUser adm `

                            -GuestPassword Pass `

                            -ScriptType bat `

                            -Scripttext "wusa.exe C:\rollup\Windows6.1-KB3020369-x64.msu /quiet /forcerestart" -ErrorAction SilentlyContinue

Invoke-VMScript -VM $backVM -GuestUser adm `

                            -GuestPassword Pass `

                            -ScriptType bat `

                            -Scripttext "wusa.exe C:\rollup\windows6.1-kb3125574-v4-x64_ROLLUP-2008R2sp1-W7sp1sp1.msu /quiet /forcerestart" -ErrorAction SilentlyContinue

sleep -Seconds 600

Invoke-VMScript -VM $backVM -GuestUser adm -GuestPassword Pass `

                            -ScriptType bat -Scripttext "RD /S /Q C:\rollup" -ErrorAction SilentlyContinue

}

0 Kudos
LucD
Leadership
Leadership

And when you launch a PS session on the remote station, does the NET USE work from a PS prompt?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DCasota
Expert
Expert

on a vanilla 2008 system it might be a ps version related issue.

https://devblogs.microsoft.com/powershell/powershell-v2-backward-compatibility/

0 Kudos
IKirill
Enthusiast
Enthusiast

This work fine locally on WS2008r2 with PS2.0

$net = new-object -ComObject WScript.Network

$net.MapNetworkDrive("y:", "\\10.2.0.254\D", $false, "administrator", "Pass")

how can we screen these 2 lines for PowerCli?

0 Kudos
LucD
Leadership
Leadership

Does this mean that 'NET USE...' from the PS prompt does not work, when run on the target station?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
IKirill
Enthusiast
Enthusiast

'NET USE...' from the PS prompt works fine locally!

0 Kudos
LucD
Leadership
Leadership

There have been some issues with VMware Tools (older versions) running on non-en-US language (French,Russion...) Windows platforms.

These were primarily related to OSGuestCustomization.

Which VMware Tools version is running on that station?
Is it a version that corresponds with the vSphere version where the VM is hosted?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos