|Author||Andreas Jordan (@JordanOrdix), ordix.de|
Returns firewall rules for SQL Server instances from the target computer.
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.
Get-DbaFirewallRule [-SqlInstance] <DbaInstanceParameter> [[-Credential] <PSCredential>] [[-Type] <String>] [-EnableException] [<CommonParameters>]
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.
PS C:\> Get-DbaFirewallRule -SqlInstance SRV1\SQL2016 -Type Engine
Returns only the firewall rule for the instance SQL2016 on SRV1.
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.
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.
The target SQL Server instance or instances.
Credential object used to connect to the Computer as a different user.
Returns firewall rules for the given type(s).
Valid values are:
Engine - for the SQL Server instance
Browser - for the SQL Server Browser
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.
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.