How to Export and Import a Specific Firewall Rule in Windows 10
In Windows 10, you can configure Windows Firewall to have custom rules for a specific address, port or protocol. You can allow or block an app from accessing the Internet. Once you do this, it is a good idea to backup your Firewall configuration.However, Windows 10 allows only exporting and importing the entire rule set. Here's a trick that we can use to export and import a specific rule only.Having a backup of firewall rules is very useful. If you reinstall Windows 10, you will be able to restore your custom rules quickly. Or, if you need to reset the Windows Firewall configuration, then having the ability to restore the custom configuration is very time saving.
Before you continue, see how to block any app from accessing Internet with one click in Windows 10, Windows 8 and Windows 7.
Backup and Restore Firewall Rules
In Windows 10, there are several ways to create a backup of Firewall rules. You can use Windows Firewall with Advanced Security snap-in to create or restore rules, or you can do it with the built-in console command netsh. Both methods reviewed in the post
How to Backup and Restore Firewall Rules in Windows 10
Unfortunately, Windows 10 doesn't offer an option to backup and restore individual Firewall rules. However, it is still possible with either PowerShell, or Registry Editor.
To Export and Import a Specific Firewall Rule in Windows 10,
- Open PowerShell as Administrator.
- Change PowerShell Execution policy to Unrestricted.
- Type the following command:
Install-Module -Name Firewall-Manager, and hit the Enter key.
- Answer [Y] to proceed.
- Answer [Y] to install the module from PSGallery.
- Type the following command and hit the Enter key:
- To export a specific firewall rule, type
Export-FirewallRules -Name "<Rule name>" -CSVFile "<Path to the CSV>" file. Specify the rule name you want to export, and provide the path to the CSV file the rule will be saved to. For example,
Export-FirewallRules -Name "IRC Port" -CSVFile c:\data\winaero\irc_port.csv".
- To import a firewall rule, type
Import-FirewallRules <path to csv file>. Provide the full path the CSV file that stores a previously exported rule. For example,
You are done.
Note the Export-FirewallRules and Import-FirewallRules cmdlets support exporting/importing of multiple rules at once, and also can work with JSON files.
To learn more about them, execute
Tip: In PowerShell, you can list existing Firewall rules as follows:
If you are not a fan of PowerShell, you can export and import a firewall rule using the Registry Editor.
Export and Import a Specific Firewall Rule with Registry Editor
First of all, you need to export all available firewall rules to a single file. You can find names for Firewall rules in PowerShell, as mentioned above, or with Windows Firewall with Advanced Security. Press Win + R and type
wf.msc in the Run box to open it.
Click on Inbound Rules/Outbound rules on the left to see the list of rules.
To export all firewall rules using Registry Editor,
- Open the Registry Editor app.
- Go to the following Registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy. See how to go to a Registry key with one click.
- Right-click on the FirewallRules folder on the left and select Export... from the context menu.
- Type in the file name for the *.reg file.
- Click on the Save button.
Now, the Registry file contains the entire set of your Firewall rules. You need to leave there only the rules you want to export, and delete all other lines.
Export Only Specific Rules to Registry File
- Right-click your *.reg file in File Explorer and select Edit from the context menu to open it in Notepad.
- Below the line
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules], you will see all the rules listed.
- Remove all of them except those you want to export. The following screenshot demonstrates how to keep only one rule in the file.
- Save the changes you made (Press Ctrl + S).
This way, you can make the reg file store only the specific rules you want to export. You can search for the rule name with Ctrl + F in Notepad to save your time.
Import Windows Firewall Rules from Registry File
- Locate the *.reg file that contains your Firewall rules in File Explorer.
- Double-click on it to merge it. Confirm the UAC prompt.
- Restart Windows 10 to ensure that the rules are properly applied.
You are done.
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
7 thoughts on “Export and Import Specific Firewall Rule in Windows 10”
This is a very good and useful tip. Thanks. I prefer the Registry/Notepad method, not PowerShell.
For PowerShell, it is hard to remember its syntax and cmdlet names.
I realize that my comment has little or nothing to do with the topick, but I need some help. I am not totally illiterate to the computer, but am not familiar with the terminology. My Windows 7/8 spider solitaire was removed during a windows update. I have tried desperately to retrieve it with no luck. Can somebody give me step by step instructions please
Hi. You just need install the games again.
On a fresh Windows 10 installation I used WinAeroTweaker to make the OS a bit more user friendly.
It is a great tool (especially since one can check what the twek do where to attain the desired effects !)
One bug I have on my system is that when I click on Network / “Export specific Firewall Rules” The program hangs ans stays in a not responding state. I have to kill it.
It might have something to do with the Execution policies of the Power-Shell “Export-FirewallRules” module.
I just have to remember never to click on that item ;-)
nope, it is not related to PowerShell.
It is some loop issue in the app.
I am working to resolve it.
seems nothing works right with powershell, always have to fiddle with this, wiggle that and takes so much time versus a reg edit.