SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell

SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell. Don’t disable Windows Firewall in your SCCM labs.

Is Windows Firewall disabled in your SCCM / ConfigMgr client machine? Is this because you are lazy to configure or create Inbound and Outbound rules for the applications like SCCM?

OK, I’m also becoming lazy these days for some good reasons šŸ™‚ We can use PowerShell commands to create and enable firewall rules, and it’s not complex at all.

SCCM ConfigMgr Client How to Create Windows Firewall

In this post, I will give a walk-through to create Outbound Windows Firewall rules for SCCM / ConfigMgr 2012 client using PowerShell commands.

Patch My PC

I’ve already blogged about creating Inbound rules in Windows Firewall. More detailsĀ on How to Create Windows Firewall Inbound Rules for SCCM ConfigMgr 2012 Client. Following are the topic that I’m going to cover in this post.

1. Import the Powershell Security module for Windows Firewall

2. Powershell command to list all the noun commands which has “Firewall” word

3. PowerShell command to Edit/Enable the Outbound Predefined rule in Windows Firewall

4. PowerShell command to create a predefined rule in Windows Firewall

5.  Powershell command to Create Outbound Firewall rule for TCP Port

6.  Powershell command to Create Outbound Firewall rule for UDP Port

7. List of all the noun commands which has “Firewall” word

Each topic is covered with screenshots and respective PowerShell commands. I’m still learning PowerShell (taking baby steps), so there could be other/better ways to achieve this task. All these topics are selected forĀ SCCM 2012 client outbound communication port requirements. SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell?

1. Import the Powershell Security module for Windows Firewall.

We need to load the Windows Firewall Module as shown in the command line. Ensure that you run all these following commands with Windows PowerShell ISE as administrator.

PS C:\Windows\system32> Import-Module NetSecurity

2. Powershell command for listing all the noun commands which has “Firewall” word

GCM command will give us a List of all the noun commands which has “Firewall” word. More Detailed Table of available commands at the bottom of the post.

PS C:\Windows\system32> gcm -noun *Firewall*

Adaptiva
SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell
SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell

3. PowerShell command to Edit/Enable the Predefined rule in Windows Firewall

Run the PowerShell command to Edit/Enable the Predefined rule in Windows Firewall for File and Printer Sharing Group.

This is a bit tricky as there are two parts to it. When we already have Windows Firewall rules for the File and Printer sharing group, we can run the following command to enable those rules. The second part is covered in point #4. For SCCM/ConfigMgr 2012 client, we need to allow theĀ Inbound and Outbound Firewall rules for all the predefined ones under File and Printer Sharing group.

Get-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Direction Outbound | Set-NetFirewallRule -Enabled True -Direction Outbound

All the Firewall Rules related to File and Printer Sharing are disabled 

SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell
SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell

Run the following Powershell command to LIST and enable already created rules under File and Printer Sharing

LIST Command:- (Get-NetFirewallRule -DisplayGroup “File and Printer Sharing” -Direction Outbound).DisplayName

To Enable:- Get-NetFirewallRule -DisplayGroup “File and Printer Sharing” -Direction Outbound | Set-NetFirewallRule -Enabled True -Direction Outbound

SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell
SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell

Ā Rules under the File and Printer sharing group has been enabled now

SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell
SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell

 4. PowerShell command to create a predefined rule in Windows Firewall

When there are no Predefined firewall rules present in the Windows Firewall console, then we can’t use the SET-NetFirewallRule PowerShell command. Rather we should use New-NetFirewallRule to create a new predefined rule in Windows Firewall console.

Powershell WF 8

Powershell command:- New-NetFirewallRule -DisplayName “File and Printer Sharing (NB-Datagram-Out)” -group “File and Printer Sharing” -Enabled True -Protocol udp -RemotePort 138 -Direction Outbound

SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell
SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell

File and Printer Sharing (NB-Datagram-Out) rule has been created. Result screenshot after running the Powershell as mentioned above command.

Powershell WF 15

5.  Powershell command to Create Outbound Firewall rule for TCP Port

Run the following Powershell command to create Outbound Firewall rule for TCP Port 80 HTT communicationon

Powershell CMD : – New-NetFirewallRule -direction outbound -InterfaceType Any -Protocol TCP -RemotePort 80 -DisplayName “HTTP Communication”

SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell
SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell
Run the following command to create Outbound Firewall rule for Client Notification TCP Port 10123

PS C:\Windows\system32> New-NetFirewallRule -direction outbound -InterfaceType Any -Protocol TCP -RemotePort 10123 -DiplayName “Client Notification TCP Port”Name : {42455662-3830-407c-9d1c-ee74b0313a73}
DisplayName : Client Notification TCP Port
Description :
DisplayGroup :
Group :
Enabled : True
Profile : Any
Platform : {}
Direction : Outbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus: OK
Status: The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local

Powershell WF 2
Powershell WF 3

6.  Powershell command to Create Outbound Firewall rule for UDP Port 

When you use Network access protection and Wake on Lan then you need to open following UDP ports as well
  • Outbound: UDP 67 and UDP 68 for DHCP
  • Outbound: TCP 80/443 for IPsec
  • Outbound: UDP Port 25536
  • Outbound: UDP Port 9

PS C:\Windows\system32> New-NetFirewallRule -direction outbound -InterfaceType Any -Protocol UDP -RemotePort 67,68,25536,9 -DisplayName “aNetwork Access point UDP Ports”

Powershell WF 4

7. List of all the noun commands which has “Firewall” word

CommandTypeNameModuleName
FunctionCopy-NetFirewallRuleNetSecurity
FunctionDisable-NetFirewallRuleNetSecurity
FunctionEnable-NetFirewallRuleNetSecurity
FunctionGet-NetFirewallAddressFilterNetSecurity
FunctionGet-NetFirewallApplicationFilterNetSecurity
FunctionGet-NetFirewallInterfaceFilterNetSecurity
FunctionGet-NetFirewallInterfaceTypeFilterNetSecurity
FunctionGet-NetFirewallPortFilterNetSecurity
FunctionGet-NetFirewallProfileNetSecurity
FunctionGet-NetFirewallRuleNetSecurity
FunctionGet-NetFirewallSecurityFilterNetSecurity
FunctionGet-NetFirewallServiceFilterNetSecurity
FunctionGet-NetFirewallSettingNetSecurity
FunctionNew-NetFirewallRuleNetSecurity
FunctionRemove-NetFirewallRuleNetSecurity
FunctionRename-NetFirewallRuleNetSecurity
FunctionSet-NetFirewallAddressFilterNetSecurity
FunctionSet-NetFirewallApplicationFilterNetSecurity
FunctionSet-NetFirewallInterfaceFilterNetSecurity
FunctionSet-NetFirewallInterfaceTypeFilterNetSecurity
FunctionSet-NetFirewallPortFilterNetSecurity
FunctionSet-NetFirewallProfileNetSecurity
FunctionSet-NetFirewallRuleNetSecurity
FunctionSet-NetFirewallSecurityFilterNetSecurity
FunctionSet-NetFirewallServiceFilterNetSecurity
FunctionSet-NetFirewallSettingNetSecurity
FunctionShow-NetFirewallRuleNetSecurity
FunctionShow-NetFirewallRuleNetSecurity

Author

AnoopĀ isĀ Microsoft MVP! He is a Solution Architect in enterprise client management with more than 20 years of experience (calculation done in 2021) in IT. He is a blogger, Speaker, and Local User Group HTMD Community leader. His main focus is on Device Management technologies like SCCM 2012, Current Branch, and Intune. E writes about ConfigMgr, Windows 11, Windows 10, Azure AD, Microsoft Intune, Windows 365, AVD, etc…

2 thoughts on “SCCM ConfigMgr Client How to Create Windows Firewall Outbound Rules Using PowerShell”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.