Thor Logo dbatools

Remove-DbaClientAlias

View Source
Chrissy LeMaire (@cl), netnerds.net
Windows, Linux, macOS

Synopsis

Removes SQL Server client aliases from Windows registry on local or remote computers

Description

Removes SQL Server client aliases from the Windows registry by deleting entries from both 32-bit and 64-bit registry locations.
Client aliases redirect SQL Server connection requests to different servers or instances, but outdated or incorrect aliases can cause connection failures.
This function provides a programmatic way to clean up these aliases when the deprecated cliconfg.exe utility is not available or when managing multiple computers remotely.
Commonly used when decommissioning servers, updating connection strings, or troubleshooting connectivity issues caused by stale alias configurations.

Syntax

Remove-DbaClientAlias
    [[-ComputerName] <DbaInstanceParameter[]>]
    [[-Credential] <PSCredential>]
    [-Alias] <String[]>
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Remove-DbaClientAlias -ComputerName workstationX -Alias sqlps

Removes the sqlps SQL Client alias on workstationX

Example: 2
PS C:\> Get-DbaClientAlias | Remove-DbaClientAlias

Removes all SQL Server client aliases on the local computer

Required Parameters

-Alias

Specifies the SQL Server client alias name(s) to remove from both 32-bit and 64-bit registry locations.
Use this to clean up outdated aliases that redirect connections to decommissioned servers or incorrect instances.
Accepts multiple alias names for bulk cleanup operations.

PropertyValue
AliasAliasName
RequiredTrue
Pipelinetrue (ByPropertyName)
Default Value

Optional Parameters

-ComputerName

Specifies the target computer(s) where SQL Server client aliases will be removed from the Windows registry.
Use this when you need to clean up aliases on remote workstations or application servers.
Defaults to the local computer if not specified.

PropertyValue
Alias
RequiredFalse
Pipelinetrue (ByPropertyName)
Default Value$env:COMPUTERNAME
-Credential

Allows you to login to remote computers using alternative credentials

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-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.

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

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

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value