Set-NetFirewallRule alternative in Windows Server 2008

6,817

Unfortunately, you cannot perform this task using the Set-NetFirewallRule cmdlet, as the WMI calls to enable the Firewall cmdlets are only available in 2012+.

For Windows Server 2008, you can use netsh advfirewall. Example:

netsh advfirewall firewall add rule name="Name" dir=in action=allow remoteip=any

You can still use PowerShell to run this command on remote systems, of course.


Alternatively, to answer a slightly different question, you can use psexec to enable PSRemoting quickly and easily (in most security contexts).

foreach ($computer in $list) {
    psexec \\$computer -h -d powershell.exe "enable-psremoting -force"
}
Share:
6,817

Related videos on Youtube

Jeff
Author by

Jeff

Updated on September 18, 2022

Comments

  • Jeff
    Jeff over 1 year

    I am trying to Enable Powershell Remoting on a Windows Server 2008, but from what I understand, the default firewall exception is that PSRemoting is only allowed if the computer (both client and server) resides in the same local subnet.

    How to remove local subnet restriction in Windows Server 2008. I know in server 2012 and above, you can do:

    Set-NetFirewallRule –Name "Name" –RemoteAddress Any
    

    How to do exactly the same thing in Windows Server 2008?