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.