Remotely disable the Windows Firewall


Have you needed to log in remotely to a server on your WAN only to find the firewall enabled and blocking remote desktop connections?

This information comes from an occasion where a new virtual server was set up and the firewall was enabled before the remote desktop connections were allowed. As it was a virtual server hosted on a WAN site there was no other way to access the user interface other than via remote desktop.


Fortunately Powershell comes to the rescue with a couple of commands.


enter-pssession SERVER.domain.local

allows you to run commands directly against the remote server as if you were running Powershell on the console.


Start-Process netsh -ArgumentList "firewall set opmode disable"

runs the netsh command on the remote server and sets the firewall mode to disabled.

With a valid Domain Admin account and these two commands you can get access to your server, adding Remoted Desktop as an exception to the Windows Firewall and then re-enabling it again.