PowerShell Logo Small

Get-NetFirewallPortFilter



This is the built-in help made by Microsoft for the command 'Get-NetFirewallPortFilter', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 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

Retrieves port filter objects from the target computer.

SYNTAX


Get-NetFirewallPortFilter [-All [<SwitchParameter>]] [-AsJob [<SwitchParameter>]] [-CimSession <CimSession[]>] [-GPOSession <String>]
[-PolicyStore <String>] [-ThrottleLimit <Int32>] [<CommonParameters>]
Get-NetFirewallPortFilter [-AsJob [<SwitchParameter>]] [-CimSession <CimSession[]>] [-GPOSession <String>] [-PolicyStore <String>]
[-ThrottleLimit <Int32>] -AssociatedNetFirewallRule <CimInstance> [<CommonParameters>]
Get-NetFirewallPortFilter [-AsJob [<SwitchParameter>]] [-CimSession <CimSession[]>] [-DynamicTransport <DynamicTransport[]>] [-GPOSession
<String>] [-PolicyStore <String>] [-Protocol <String[]>] [-ThrottleLimit <Int32>] [<CommonParameters>]
Get-NetFirewallPortFilter [-AsJob [<SwitchParameter>]] [-CimSession <CimSession[]>] [-GPOSession <String>] [-PolicyStore <String>]
[-ThrottleLimit <Int32>] -AssociatedNetIPsecRule <CimInstance> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Get-NetFirewallPortFilter cmdlet returns the port filter objects associated with the input rules.


Port filter objects represent the port and protocol conditions associated with the firewall and IPsec rules. The Protocol, LocalPort,
RemotePort, IcmpType and DynamicTransport parameters of a single rule are represented in a single rule are represented in a separate
NetFirewallPortFilter object. The filter to rule relationship is always one-to-one and is managed automatically. Rule parameters associated
with filters can only be queried using filter objects.


This cmdlet displays the ports and protocols associated with firewall and IPsec rules. This allows for rule querying based on the Protocol,
LocalPort, RemotePort, IcmpType and DynamicTransport parameters; this cmdlet returns filter objects that may be further queried with the
Where-Object cmdlet. The cmdlet also allows the interface type filters to be obtained by Protocol, LocalPort, RemotePort, IcmpType and
DynamicTransport parameter query. The resultant filters are passed into the Get-NetFirewallRule or Get-NetIPsecRule cmdlet to return the rules
queried by port or protocol.


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


The array of NetFirewallPortFilter objects can be piped into the Get-NetFirewallRule or Get-NetIPsecRule cmdlet, which returns the rules
associated with the filters. These rules are then piped to the Set-NetFirewallRule or Set-NetIPsecRule cmdlet where the interface properties
can be configured.


Alternatively, piping the array of NetFirewallPortFilter objects directly into the Set-NetFirewallInterfaceTypeFilter cmdlet allows the
Protocol, LocalPort, RemotePort, IcmpType and DynamicTransport parameters of the rules to be modified.



<

RELATED LINKS

Format-Table
Where-Object
Get-NetFirewallRule
Get-NetIPSecRule
New-NetFirewallRule
New-NetIPSecRule
Set-NetFirewallInterfaceFilter
Set-NetFirewallPortFilter
Set-NetFirewallRule
Set-NetIPSecRule
New-GPO

REMARKS

<

Examples


Example 1

PS C:\> Get-NetFirewallPortFilter -PolicyStore ActiveStore

This cmdlet displays the same information in a dynamically sized formatted table.
PS C:\> Get-NetFirewallPortFilter -PolicyStore ActiveStore | Format-Table -Property *



This example retrieves the port conditions associated with all the rules in the active store. Note: Running this cmdlet without specifying the
policy store retrieves the persistent store.




Example 2

PS C:\> Get-NetFirewallRule –DisplayName "Contoso Messenger" | Get-NetFirewallPortFilter



This example gets the port properties of a particular firewall rule.




Example 3

PS C:\> Get-FirewallRule –DisplayName "Play To streaming server" | Get-NetFirewallPortFilter | Set-NetFirewallPortFilter –LocalPort 10246

This task can alternatively be done with this cmdlet.
PS C:\> Set-NetFirewallRule –DisplayName "Play To streaming server" –LocalPort 10246



This example modifies the local port field of a particular firewall rule.




Example 4

PS C:\> Get-NetFirewallPortFilter | Where-Object -Property { $_.LocalPort -Eq "10246" } | Set-NetFirewallPortFilter –LocalPort Any



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




Example 5

PS C:\> Get-NetFirewallRule –DisplayGroup "File and Printer Sharing" | Get-NetFirewallPortFilter | Where-Object -Property { $_.RemotePort –Eq
"137" } | Set-NetFirewallPortFilter –LocalPort Any



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




Example 6

PS C:\> Get-NetFirewallPortFilter -DynamicTransport ProximitySharing | Get-NetFirewallRule | Set-NetFirewall –Action Block



This example shows how to locate the built-in network isolation rule permitting ProximitySharing and blocks it so that the proximity pairing
is disallowed.