문제

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
도움이 되었습니까?

해결책

try calling this in the beginning of the script:

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

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top