我有一个包含PowerCLI命令的powershell脚本文件,比如Connect-VIServer等。在我将库引用添加到VMWare PowerCLI之后,我可以在PowerGUI中运行该脚本文件,但我不知道如何通过SoapUI运行它。我猜它也不能与常规的Powershell CLI一起工作。有没有办法让这件事起作用呢?如果有帮助的话,下面是错误:
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发布于 2012-07-20 02:58:38
尝试在脚本的开头调用以下代码:
Add-PSSnapin "VMware.VimAutomation.Core" | Out-Null发布于 2012-07-21 10:56:28
您不能在Powershell主机外部执行PowerCLI命令。
要将管理单元添加到任何Powershell主机,请使用前面提到的命令Tomas:
Add-PSSnapin VMware.VimAutomation.Corehttps://stackoverflow.com/questions/11567349
复制相似问题