Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 176483

VM info is not being displayed while using PowerCLI invoked from VB Script

$
0
0

Hi,

 

I am trying to run a simple VB Script to list the VMs, Hosts and Data Centers. The script is able to create a connection and it displays "Completed execution". But, the required data is not displayed.

When I run these commands manually in powershell, I am able to get the data.

 

The code is copied below. Please help.

 

Option Explicit

 

Dim ps: ps = "powershell.exe -noninteractive -noprofile -command ""& { . \""C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\"" ; Connect-VIServer -Server <Server IP> -Protocol https -Username <Username> -Password <Password> ; Get-VM | Select Name, @{N=""VM Host""; E={Get-VMHost -VM $_}}, @{N=""Datacenter"";E={Get-Datacenter -VM $_}} ; Write-Host ""Completed execution"" }"""

 

Dim sh: Set sh = CreateObject("WScript.Shell")
Dim exec: Set exec = sh.Exec(ps)

exec.StdIn.Close()

WScript.Echo exec.StdOut.ReadAll()

 

 

Thanks in advance,

 

 

Regards,

Praveen


Viewing all articles
Browse latest Browse all 176483

Trending Articles