commands

^

Get-DbaFirewallRule

Author Andreas Jordan (@JordanOrdix), ordix.de
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Get-DbaFirewallRule on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaFirewallRule.

Synopsis

Returns firewall rules for SQL Server instances from the target computer.

Description

Returns firewall rules for SQL Server instances from the target computer.
As the group and the names of the firewall rules are fixed, this command
only works for rules created with New-DbaFirewallRule.

This is basically a wrapper around Get-NetFirewallRule executed at the target computer.
So this only works if Get-NetFirewallRule works on the target computer.

The functionality is currently limited. Help to extend the functionality is welcome.

As long as you can read this note here, there may be breaking changes in future versions.
So please review your scripts using this command after updating dbatools.

Syntax

Get-DbaFirewallRule
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-Credential] <PSCredential>]
    [[-Type] <String[]>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaFirewallRule -SqlInstance SRV1

Returns the firewall rule for the default instance on SRV1.
In case the instance is not listening on port 1433, it also returns the firewall rule for the SQL Server Browser.

Example: 2
PS C:\> Get-DbaFirewallRule -SqlInstance SRV1\SQL2016 -Type Engine

Returns only the firewall rule for the instance SQL2016 on SRV1.

Example: 3
PS C:\> Get-DbaFirewallRule -SqlInstance SRV1\SQL2016 -Type Browser
PS C:\> Get-DbaFirewallRule -SqlInstance SRV1 -Type Browser

Both commands return the firewall rule for the SQL Serer Browser on SRV1.
As the Browser is not bound to a specific instance, only the computer part of SqlInstance is used.

Example: 4
PS C:\> Get-DbaFirewallRule -SqlInstance SRV1\SQL2016 -Type AllInstance

Returns all firewall rules on the computer SRV1 related to SQL Server.
The value "AllInstance" only uses the computer name part of SqlInstance.

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-Credential

Credential object used to connect to the Computer as a different user.

Alias
Required False
Pipeline false
Default Value
-Type

Returns firewall rules for the given type(s).
Valid values are:

  • Engine - for the SQL Server instance
  • Browser - for the SQL Server Browser
  • DAC - for the dedicated admin connection (DAC)
  • AllInstance - for all firewall rules on the target computer related to SQL Server
    If this parameter is not used, the firewall rule for the SQL Server instance will be returned
    and in case the instance is listening on a port other than 1433,
    also the firewall rule for the SQL Server Browser will be returned.
Alias
Required False
Pipeline false
Default Value
Accepted Values Engine,Browser,DAC,AllInstance
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False