是否可以从远程Powershell会话运行Vmware PowerCLI?

时间:2016-03-21 05:37:47

标签: powershell vmware powercli

我使用PSSession命令通过Powershell从桌面连接到服务器。在远程服务器上安装了VMware PowerCLI。我试图运行下面的模块......

 > PS C:\Users\cwip0989\Documents> Enter-PSSession -ComputerName AB-NPC1-D1B099 -Credential cwip0989
[AB-NPC1-D1B099]: PS C:\Users\cwip0989\Documents> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c ".\"
    'C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\'""
The remote pipeline has been stopped.
        + CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException

    [AB-NPC1-D1B099]: PS C:\Users\cwip0989\Documents> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c ".\"
    'C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\'""
    The remote pipeline has been stopped.
        + CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException

我认为,毕竟Powershell Scripting存在一些限制。

我也发现了一件事,远程PowerShell版本总是2.1 ......

[AB-NPC1-1B094]: PS C:\> $psversiontable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5485
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

1 个答案:

答案 0 :(得分:0)

请查看invoke-vmscript 它可用于在远程服务器上运行命令,但无需执行pssession。但是,这不会在桌面的PowerShell或powercli中为您提供命令的输出。