Powershell 使用SoapUI运行VMWare powerCLI命令

Powershell 使用SoapUI运行VMWare powerCLI命令,powershell,vmware,soapui,powercli,Powershell,Vmware,Soapui,Powercli,我有一个powershell脚本文件,其中包含诸如Connect VIServer等PowerCLI命令。在我将库引用添加到VMWare PowerCLI后,我可以在PowerGUI中运行该脚本文件,但我不知道如何通过SoapUI运行它。我猜它也无法与常规Powershell CLI配合使用。有什么办法可以让这一切顺利进行吗?下面是错误,如果有帮助的话: The term 'Connect-VIServer' is not recognized as the name of a cmdlet,

我有一个powershell脚本文件,其中包含诸如Connect VIServer等PowerCLI命令。在我将库引用添加到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
术语“Connect-VIServer”无法识别为cmdlet函数的名称
、脚本文件或可操作程序。检查姓名的拼写,或者是否有拼写错误
已包含h,请验证路径是否正确,然后重试。
测试时,ps1:10字符:23

+$vm=Connect-VIServer尝试在脚本开头调用此命令:

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

您不能在Powershell主机之外执行PowerCLI命令

要将管理单元添加到任何Powershell主机,请使用命令Tomas:

Add-PSSnapin VMware.VimAutomation.Core

在soapUI中将其添加到Groovy脚本中,并得到一系列错误:org.codehaus.Groovy.control.multipleCompileOnErrorSexception:启动失败:Script2.Groovy:1:预期EOF,发现“VMware.VimAutomation.Core”也尝试将其添加到Powershell脚本中,但发现它是一个脚本,不适用于Groovy:D。没有帮助:(我意识到,如果我可以从普通的windows命令提示符运行脚本,我就可以做到这一点。在SoapUI中的Groovy脚本中,我执行这个命令“powershell Test.ps1”。如果我使用类似“powercli Test.ps1”的命令,它可能对我有效。不幸的是,这不起作用。有这样的神奇命令吗?