PowerShell Logo Small

Set-NetFirewallPortFilter



This is the built-in help made by Microsoft for the command 'Set-NetFirewallPortFilter', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Modifies port filter objects, thereby modifying the protocol and port conditions using the Protocol, LocalPort, RemotePort, IcmpType, and DynamicTransport parameters of the firewall or IPsec rules.

SYNTAX


Set-NetFirewallPortFilter [-AsJob] [-CimSession <CimSession[]>] [-DynamicTarget <DynamicTransport>] [-GPOSession <String>] [-IcmpType <String[]>] [-LocalPort <String[]>]
[-PassThru] [-PolicyStore <String>] [-Protocol <String>] [-RemotePort <String[]>] [-ThrottleLimit <Int32>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-NetFirewallPortFilter [-AsJob] [-CimSession <CimSession[]>] [-DynamicTarget <DynamicTransport>] [-IcmpType <String[]>] [-LocalPort <String[]>] [-PassThru] [-Protocol
<String>] [-RemotePort <String[]>] [-ThrottleLimit <Int32>] -InputObject <CimInstance[]> [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-NetFirewallPortFilter cmdlet modifies the protocol and port conditions using the Protocol, LocalPort, RemotePort, IcmpType, and DynamicTransport parameters
associated with the input firewall or IPsec rules.


See the Get-NetFirewallPortFilter cmdlet for more information about the interface type filters.


To modify the port and protocol conditions, two methods can be used starting with the port filters returned by the Get-NetFirewallPortFilter cmdlet and optional additional
querying.

-- The network firewall port filter objects are piped into the Get-NetFirewallRule or Get-NetIPsecrule cmdlet. The Get-NetFirewallRule or Get-NetIPsecrule cmdlet returns
the rules associated with the filters and pipes the rules into the Set-NetFirewallRule or Set-NetIPsecrule cmdlet which configures the interface properties.

-- Alternatively, the network firewall port filter objects are piped directly to this cmdlet, which modifies the Protocol, LocalPort, RemotePort, IcmpType, and
DynamicTransport parameters values of the rules.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkId=288214
Where-Object
Copy-NetIPsecRule
Get-NetFirewallPortFilter
Get-NetFirewallRule
Get-NetIPSecRule
New-NetFirewallRule
New-NetIPSecRule
Set-NetFirewallRule
Set-NetFirewallSetting
Set-NetIPSecRule
New-GPO

REMARKS

<

Examples


EXAMPLE 1

PS C:\>$nfPortFilter = Get-FirewallRule –DisplayName "Play To streaming server" | Get-NetFirewallPortFilter



PS C:\>Set-NetFirewallPortFilter –LocalPort 10246 –InputObject $nfPortFilter


This cmdlet can be run using only the pipeline.
PS C:\>Get-FirewallRule –DisplayName "Play To streaming server" | Get-NetFirewallPortFilter | Set-NetFirewallPortFilter –LocalPort 10246


This cmdlet can be run without the pipeline.
PS C:\>Set-NetFirewallRule –DisplayName "Play To streaming server" –LocalPort 10246



This example modifies the LocalPort parameter value of the specified firewall rule.




EXAMPLE 2

PS C:\>$nfPortFilter = Get-NetFirewallPortFilter



PS C:\>$nfPortFilter10246 = Where-Object –FilterScript { $_.LocalPort -Eq "10246" } –InputObject $nfPortFilter



PS C:\>Set-NetFirewallPortFilter –LocalPort Any –InputObject $nfPortFilter10246


This cmdlet can be run using only the pipeline.
PS C:\>Get-NetFirewallPortFilter | Where-Object –FilterScript { $_.LocalPort -Eq "10246" } | Set-NetFirewallPortFilter –LocalPort Any



This example modifies all of the rules associated with a specific port.




EXAMPLE 3

PS C:\>$nfPortFilter = Get-NetFirewallRule –DisplayGroup "File and Printer Sharing" | Get-NetFirewallPortFilter



PS C:\>$nfPortFilter137 = Where-Object –FilterScript { $_.RemotePort –Eq "137" } –InputObject $nfPortFilter



PS C:\>Set-NetFirewallPortFilter –LocalPort Any –InputObject $nfPortFilter137


This cmdlet can be run using only the pipeline.
PS C:\>Get-NetFirewallRule –DisplayGroup "File and Printer Sharing" | Get-NetFirewallPortFilter | Where-Object –FilterScript { $_.RemotePort –Eq "137" } |
Set-NetFirewallPortFilter –LocalPort Any



This example modifies the interface type associated with all of the firewall rules in a specified group.