commands

^

New-DbaClientAlias

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

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

Synopsis

Creates/updates a sql alias for the specified server - mimics cliconfg.exe

Description

Creates/updates a SQL Server alias by altering HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client

Syntax

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

 

Examples

 

Example: 1
PS C:\> New-DbaClientAlias -ServerName sqlcluster\sharepoint -Alias sp

Creates a new TCP alias on the local workstation called sp, which points sqlcluster\sharepoint

Example: 2
PS C:\> New-DbaClientAlias -ServerName 'sqlcluster,14443' -Alias spinstance

Creates a new TCP alias on the local workstation called spinstance, which points to sqlcluster, port 14443.

Example: 3
PS C:\> New-DbaClientAlias -ServerName sqlcluster\sharepoint -Alias sp -Protocol NamedPipes

Creates a new NamedPipes alias on the local workstation called sp, which points sqlcluster\sharepoint

Required Parameters

-ServerName

The target SQL Server

Alias
Required True
Pipeline true (ByValue)
Default Value
-Alias

The alias to be created

Alias
Required True
Pipeline false
Default Value

Optional Parameters

-ComputerName

The target computer where the alias will be created

Alias
Required False
Pipeline false
Default Value $env:COMPUTERNAME
-Credential

Allows you to login to remote computers using alternative credentials

Alias
Required False
Pipeline false
Default Value
-Protocol

The protocol for the connection, either TCPIP or NetBIOS. Defaults to TCPIP.

Alias
Required False
Pipeline false
Default Value TCPIP
Accepted Values TCPIP,NamedPipes
-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