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