georgep
Contributor
Contributor

Running PowerCLi commands from a remote server. Some work but some dont.

Two examples of accessing PowerCLI cmdlets from a remote machine.

Works

invoke-command  -ComputerName blah -Scriptblock {add-pssnapin VMware.VimAutomation.Core; Connect-VIServer -Server myVC -WarningAction SilentlyContinue}

invoke-command  -ComputerName blah -Scriptblock {add-pssnapin VMware.VimAutomation.Core; Connect-VIServer -Server myVC -WarningAction SilentlyContinue; get-vm} | select Name

Does not work

invoke-command -ComputerName blah -Scriptblock {add-pssnapin VMware.VimAutomation.Core; Open-VMConsoleWindow My VM}

Reply
0 Kudos
LucD
Leadership
Leadership

I'm not sure you can even open a console on a remote station like this.

Under which session would the browser be opened ?

Just to check, did you also specify the correct 32-bit browser through Set-PowerCLICOnfiguration on the remote station ?


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

Reply
0 Kudos
georgep
Contributor
Contributor


Hi LucD,

The remote machine  Blah that has PowerCLi installed does use  a 32-bit browser. If I run the Open-VMConsoleWindow  locally on it, it  loads IE 9 and opens the console window to the VM fine.

When I run this from a remote machine to the one above it doesn't error but just returns saying completed.

Invoke-Command -ComputerName Blah -Scriptblock {add-pssnapin VMware.VimAutomation.Core; Connect-VIServer -Server MyVC -WarningAction SilentlyContinue; Open-VMConsoleWindow MyVM}

Watching the task manager on both machines doesn't show a browser trying to load.

So getting access to a VM consoles without PowerCLI installed locally might not seem possible. So another approach I am looking at might be to use

vmware-vmrc.exe

Example when run from machine Blah

Connect-VIServer = MyVC

$vm = Get-VM MyVM

$gvm = Get-View $vm.id

$moref = $gvm.MoRef.Value

$Parameters = " -h MyVC -M $moref"

Start-Process -FilePath "C:\Program Files (x86)\Common Files\VMware\VMware VMRC Plug-in\Internet Explorer\vmware-vmrc.exe" -ArgumentList $Parameters


Is there a way to run this from a remote machine that doesn't have vmware-vmrc.exe installed?

Reply
0 Kudos
LucD
Leadership
Leadership

I suspect it might be opening the console under the local system account on the remote machine.

You will not see the browser that way.

Can you check with Get-Process if the browser is running ?

You could try to run the remote PowerCLI cmdlets under a different account by using

$rSession = New-PSSession -Credential $credential

Invoke-Command -Session $rSession ...

but I'm not sure if that will actually show the console in the browser in the session.


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

Reply
0 Kudos