我使用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脚本有一些局限性。
我还发现一件事,远程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发布于 2016-04-01 22:16:48
请看一下invoke-vmscript,它可以用来在远程服务器上运行命令,但不需要做pssession。但是,这不会在桌面的powershell或powercli中给出命令的输出。
https://stackoverflow.com/questions/36123863
复制相似问题