How to enable remote Powershell Script execution

Posted on Updated on

I develop and run quite a few little network scripts to automate repetitive and mundane tasks, and I try as much as possible to do this remotely, without requiring to log onto a particular machine.

I recently ran into a Powershell error that prevented enabling remote Powershell Script running, using the command Enable-PSRemoting.

There is a technet article here that describes what this command does (And another quick howto here) and some potential troubleshooting methods, but this isnt entirely straightforward. Most importantly, what happens when you encounter this error:

Set-WSManQuickConfig : Unable to check the status of the firewall.

Interestingly, there is another command, winrm quickconfig, which comes in handy for readying and enabling the WinRM (Windows Remote Management) service quickly (There is a quick introduction to WinRM here, and more detailed technet details here). This second command also returned an error, so required some investigation:

PS C:Windowssystem32> winrm quickconfig
WinRM already is set up to receive requests on this machine.
WSManFault
  Message
    ProviderFault
      WSManFault
      Message = Unable to check the status of the firewall.
Error number: -2147024894 0x80070002
The system cannot find the file specified.

As it turns out, the ‘Windows Remote Management(HTTP-In)‘ service needs to be added as an INBOUND rule to the Windows Firewall, or it will fail.

Lastly, as a word of caution, be sure to secure your systems from remote connections from outside as the above methods open up your system to remote script execution.

Advertisements

2 thoughts on “How to enable remote Powershell Script execution

    Mirek said:
    August 31, 2016 at 9:37 am

    I’m getting exactly the same error but i’ve this rule allowed.

    Like

    fdjkfjslj said:
    October 17, 2016 at 7:05 am

    >I’m getting exactly the same error but i’ve this rule allowed.
    me too….
    is that have something to do with wifi?

    Like

Leave a Reply if you find this useful

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s