简体   繁体   中英

PowerShell: error executing command using Invoke-Command?

I'm trying to execute the following statement on remoter server:

Invoke-Command -ComputerName server1 -ScriptBlock {Get-Process}

but I get an error message:

[server1] Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the serv
ice on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS
 or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more 
information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException
    + FullyQualifiedErrorId : PSSessionStateBroken

What is the reason for this and how to fix it?

There is 2 basical reason:

1) remote computer has not Powershell installed

2) PSremoting is not enabled on remote PC (to enable it read my comment in you answer)

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