Question

I have a powershell script file with PowerCLI commands like Connect-VIServer etc. I am able to run the script file in PowerGUI after I added the library references to VMWare PowerCLI but I don't know how to run it through SoapUI. I'm guessing it won't work with the regular Powershell CLI either. Is there any way to make this work? Here's the error, if it helps:

The term 'Connect-VIServer' is not recognized as the name of a cmdlet, function
, script file, or operable program. Check the spelling of the name, or if a pat
h was included, verify that the path is correct and try again.
At Test.ps1:10 char:23
+ $vm = Connect-VIServer <<<<  -Server $vcenterIP -User $vcenterUser -Password 
$vcenterPW
    + CategoryInfo          : ObjectNotFound: (Connect-VIServer:String) [], Co 
   mmandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Was it helpful?

Solution

try calling this in the beginning of the script:

Add-PSSnapin "VMware.VimAutomation.Core" | Out-Null

OTHER TIPS

You cannot execute PowerCLI commands outside of a Powershell host.

To add the snap-in to any Powershell host, use the command Tomas mentioned:

Add-PSSnapin VMware.VimAutomation.Core
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top