简体   繁体   中英

Is it possible to run Vmware PowerCLI from Remote Powershell Session?

I'm connecting to a server from my desktop through Powershell using PSSession command . On the remote server there is VMware PowerCLI installed. I'm trying to run the module like below...

 > 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

I believe there are some limitations in Powershell Scripting, after all .

Also I found one thing, the remote powershell version is always 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

Please have a look at invoke-vmscript which can be used to run commands on a remote server but without having to do a pssession. This will however not give you the output of the command in your desktop's powershell or powercli.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM