Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 309
jrara Avatar asked Sep 07 '11 09:09

jrara


People also ask

What is invoke-command in PowerShell?

Description. The Invoke-Command cmdlet runs commands on a local or remote computer and returns all output from the commands, including errors. Using a single Invoke-Command command, you can run commands on multiple computers. To run a single command on a remote computer, use the ComputerName parameter.

What does invoke item do in PowerShell?

Description. The Invoke-Item cmdlet performs the default action on the specified item. For example, it runs an executable file or opens a document file in the application associated with the document file type.


1 Answers

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)

like image 139
CB. Avatar answered Oct 05 '22 10:10

CB.