PowerShell Logo Small

Get-NetFirewallPortFilter



This is the built-in help made by Microsoft for the command 'Get-NetFirewallPortFilter', in PowerShell version 4 - as retrieved from Windows version 'Microsoft Windows 8.1 Enterprise' 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] [-AsJob] [-CimSession <CimSession[]>] [-GPOSession <String>] [-PolicyStore <String>] [-ThrottleLimit <Int32>] [<CommonParameters>]
Get-NetFirewallPortFilter [-AsJob] [-CimSession <CimSession[]>] [-DynamicTarget <DynamicTransport[]>] [-GPOSession <String>] [-PolicyStore <String>] [-Protocol <Strin
g[]>] [-ThrottleLimit <Int32>] [<CommonParameters>]
Get-NetFirewallPortFilter [-AsJob] [-CimSession <CimSession[]>] [-GPOSession <String>] [-PolicyStore <String>] [-ThrottleLimit <Int32>] -AssociatedNetFirewallRule <Ci
mInstance> [<CommonParameters>]
Get-NetFirewallPortFilter [-AsJob] [-CimSession <CimSession[]>] [-GPOSession <String>] [-PolicyStore <String>] [-ThrottleLimit <Int32>] -AssociatedNetIPsecRule <CimIn
stance> [<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 Dynamic
Transport 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, Icm
pType and DynamicTransport parameters; this cmdlet returns filter objects that may be further queried with the Where-Object cmdlet. The cmdlet also allows the interfa
ce type filters to be obtained by Protocol, LocalPort, RemotePort, IcmpType and DynamicTransport parameter query. The resultant filters are passed into the Get-NetFir
ewallRule 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, RemotePor
t, IcmpType and DynamicTransport parameters of the rules to be modified.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkId=282432
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-NetFirewall
PortFilter –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.