invoke-command and enable-psremoting -force

Today seems to be PowerShell issue day and it was such a nice day until I had to remote into a new machine.

I tried running

invoke-command -computer $server {get-process | where-object {$_.Name -like "B*"}

And then I got this message and it is no longer such a nice day.

[yourserverhere] Connecting to remote server failed with the following error message : The client cannot connect to the dest
ination specified in the request. Verify that the service on the destination is running and is accepting requests. Cons
ult 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

But wait, what do I hear rustling in the bushes… can it be.. Yes it is!! enable-psremoting –force to the rescue.

enable-psremoting -force
WinRM already is set up to receive requests on this machine.
WinRM has been updated for remote management.
Created a WinRM listener on HTTP://* to accept WS-Man requests to any IP on this machine.
WinRM firewall exception enabled.



0 views0 comments

Recent Posts

See All

PowerShell Set-ExecutionPolicy Giving error

If you ever get this error the whole time, do not stress. Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.