Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save makeitcloudy/9bed7d905e6b6d43ff67c719431dec8c to your computer and use it in GitHub Desktop.
Save makeitcloudy/9bed7d905e6b6d43ff67c719431dec8c to your computer and use it in GitHub Desktop.
#Does anybody know a way to add an Inbound Firewall Rule to a GPO using PowerShell?
#Below is example for WinRM inbound rule
$domain = "abc.com\"
$GpoName = "Global-WinRM"
$PolicyStoreName = $domain + $GpoName
$GpoSessionName = Open-NetGPO –PolicyStore $PolicyStoreName
New-NetFirewallRule -Name "Windows Management I" `
-DisplayName "Windows Management Instrumentation (ASync-In)" `
-Group "@FirewallAPI.dll,-34251" `
-Program "%systemroot%\system32\wbem\unsecapp.exe" `
-Profile Domain `
-Action Allow `
-GPOSession $GpoSessionName `
-Verbose
Save-NetGPO -GPOSession $GpoSessionName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment