Remove-​Sql​Firewall​Rule

Disables the Windows Firewall rule that allows connections to a specific instance of SQL Server.

Syntax

Remove-SqlFirewallRule
      [-Credential] <PSCredential>
      [-Path <String[]>]
      [-AutomaticallyAcceptUntrustedCertificates]
      [-ManagementPublicPort <Int32>]
      [-RetryTimeout <Int32>]
      [-InformationAction <ActionPreference>]
      [-InformationVariable <String>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-SqlFirewallRule
      [-Credential] <PSCredential>
      [-AutomaticallyAcceptUntrustedCertificates]
      [-ManagementPublicPort <Int32>]
      [-RetryTimeout <Int32>]
      [-InformationAction <ActionPreference>]
      [-InformationVariable <String>]
      [-WhatIf]
      [-Confirm]
      -InputObject <Server[]>
      [<CommonParameters>]
Remove-SqlFirewallRule
      [-Credential] <PSCredential>
      [-AutomaticallyAcceptUntrustedCertificates]
      [-ManagementPublicPort <Int32>]
      [-RetryTimeout <Int32>]
      [-InformationAction <ActionPreference>]
      [-InformationVariable <String>]
      [-WhatIf]
      [-Confirm]
      -ServerInstance <String[]>
      [<CommonParameters>]

Description

The Remove-SqlFirewallRule cmdlet disables the Windows Firewall rule that allows connections to a specific instance of SQL Server.

SQL Server Cloud Adapter must be running and accessible on the computer that hosts the instance of SQL Server.

This cmdlet supports the following modes of operation:

  • Specify the instance Windows PowerShell path.
  • Specify the server object.
  • Specify the ServerInstance object of the target instance of SQL Server.

Examples

Example 1: Disable a Windows Firewall rule that blocks connections to a SQL Server instance

PS C:\> CD SQLSERVER:\SQL\Computer\Instance;
PS SQLSERVER:\SQL\Computer\Instance> Remove-SqlFirewallRule -Credential $Credential -AcceptSelfSignedCertificate

This command disables the Windows Firewall rule on the computer to block connections to the SQL Server instance on this computer. The current working directory is used to determine the server instance where the operation should occur. The self-signed certificate of the target computer is automatically accepted without prompting the user.

Example 2: Disable a Windows Firewall rule that blocks connections to all SQL Server instances

PS C:\> Get-SqlInstance -Credential $Credential -MachineName "Computer002" | Remove-SqlFirewallRule -Credential $Credential -AcceptSelfSignedCertificate

This command gets all instances of SQL Server on the computer named Computer002 and disables the Windows Firewall rules to block connections to each one of them. The self-signed certificate of the target computer is automatically accepted without prompting the user.

Required Parameters

-Credential

Specifies a user account with Windows Administrator credentials on the target computer.

Type:PSCredential
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InputObject

Specifies the Server object, as an array, of the target instance.

Type:Server[]
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-ServerInstance

Specifies the name of an instance of SQL Server, as an array, that becomes the target of the operation.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False

Optional Parameters

-AutomaticallyAcceptUntrustedCertificates

Indicates that this cmdlet automatically accepts untrusted certificates.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-InformationAction

Specifies how this cmdlet responds to an information event.

The acceptable values for this parameter are:

  • Continue
  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ManagementPublicPort

Specifies the public management port on the target computer. This parameter should be used when the ports of the target computer are not directly accessible but are exposed through endpoints, which means that we need to connect to a different port.

SQL Server Cloud Adapter must be accessible by this port.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Path

Specifies the path to the instance of SQL Server on which this cmdlet runs the operation. If you do not specify a value for this parameter, the cmdlet uses the current working location.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-RetryTimeout

Specifies the time period to retry the command on the target sever. After the timeout expires, no retry will be attempted.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False