commands

^

Remove-DbaFirewallRule

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

 

Synopsis

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

Description

Removes 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 Remove-NetFirewallRule executed at the target computer. So this only works if Remove-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

Remove-DbaFirewallRule
    [-SqlInstance] <DbaInstanceParameter[]>
    [-Credential <PSCredential>]
    [-Type <String[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Remove-DbaFirewallRule -InputObject <Object[]>
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

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

Removes the firewall rule for the default instance on SRV1.

Example: 2
PS C:\> Remove-DbaFirewallRule -SqlInstance SRV1\SQL2016 -Type Engine, Browser

Removes the firewall rule for the instance SQL2016 on SRV1 and the firewall rule for the SQL Server Browser.

Example: 3
PS C:\> Get-DbaFirewallRule -SqlInstance SRV1 -Type AllInstance | Where-Object Type -eq 'Engine' | Remove-DbaFirewallRule

Removes the firewall rules for all instance from SRV1. Leaves the firewall rule for the SQL Server Browser in place.

Example: 4
PS C:\> Remove-DbaFirewallRule -SqlInstance SRV1 -Confirm:$false

Removes the firewall rule for the default instance on SRV1. Does not prompt for confirmation.

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required True
Pipeline false
Default Value
-InputObject

The output object(s) from Get-DbaFirewallRule.

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

Removes 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 The default is 'Engine'. As the Browser might be needed by other instances, the firewall rule for the SQL Server Browser is never removed with the firewall rule of the instance but only removed if 'Browser' is used.

Alias
Required False
Pipeline false
Default Value Engine
Accepted Values Engine,Browser,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
-WhatIf

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

Alias cf
Required False
Pipeline false
Default Value

 

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