Set-NetFirewallRule
Use Set-NetFirewallRule to change properties of existing Windows Firewall rules.
Documentation: Microsoft Learn — PowerShell module reference
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Set-NetFirewallRule [-Name] <String[]> [-DisplayName <String>] [-Enabled <Enabled>] [-Action <Action>] [-Direction <Direction>] [-Profile <Profile>] [-LocalPort <String[]>] [-RemoteAddress <String[]>] [-WhatIf] [<CommonParameters>]- Stage 1Set-NetFirewallRule
-Name -DisplayName -Enabled -Action -Direction -Profile -LocalPort -RemoteAddress -WhatIf
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Set-NetFirewallRule -DisplayName "Remote Desktop - User Mode (TCP-In)"
Show reference output
Sample output · fictional data, shaped like the real thing
Name DisplayName Enabled Direction Action ---- ----------- ------- --------- ------ e7c9f4a2-3b5d-4e8f-9a1c-2d6b7e5f8a9c Remote Desktop - User Mode (TCP-In) True Inbound Allow
Parameters
Parameter definitions:
-Name-DisplayName-Enabled-Action-Direction-Profile-LocalPort-RemoteAddress-WhatIf
Practical use and troubleshooting
Practical scenario: Use Set-NetFirewallRule when you need to change properties of existing Windows Firewall rules. Review syntax and sample output, then try an example in the browser lab. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: Access denied or an unchanged effective rule can reflect policy management. Check elevation and whether Group Policy owns the rule before trying to modify local settings. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Get-NetFirewallRule. Set-NetFirewallRule changes existing firewall rule settings; Get-NetFirewallRule reads them. Record the original rule and its policy source before applying a change. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Recap
Set-NetFirewallRule Use Set-NetFirewallRule to change properties of existing Windows Firewall rules.
Next: Get-NetFirewallRule