SqlAlias - johlju/SqlServerDsc GitHub Wiki
SqlAlias
Parameters
| Parameter | Attribute | DataType | Description | Allowed Values |
|---|---|---|---|---|
| Name | Key | String | The name of Alias (e.g. svr01\inst01). | |
| Protocol | Write | String | Protocol to use when connecting. Valid values are 'TCP' or 'NP' (Named Pipes). Default value is 'TCP'. | TCP, NP |
| ServerName | Write | String | The SQL Server you are aliasing (the NetBIOS name or FQDN). | |
| TcpPort | Write | UInt16 | The TCP port SQL is listening on. Only used when protocol is set to 'TCP'. Default value is port 1433. | |
| UseDynamicTcpPort | Write | Boolean | The UseDynamicTcpPort specify that the Net-Library will determine the port dynamically. The port specified in Port number will not be used. Default value is '$false'. | |
| Ensure | Write | String | Determines whether the alias should be added or removed. Default value is 'Present' | Present, Absent |
| PipeName | Read | String | Named Pipes path from the Get-TargetResource method. |
Description
The SqlAlias DSC resource is used to configure SQL Server Aliases on the node.
Requirements
- Target machine must be running Windows Server 2012 or later.
Known issues
All issues are not listed here, see here for all open issues.
Examples
Example 1
This example shows how to ensure that the SQL Alias SQLDSC* exists with Named Pipes or TCP.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlAlias 'Add_SqlAlias_TCP'
{
Ensure = 'Present'
Name = 'SQLDSC-TCP'
ServerName = 'sqltest.company.local\DSC'
Protocol = 'TCP'
TcpPort = 1777
PsDscRunAsCredential = $SqlAdministratorCredential
}
SqlAlias 'Add_SqlAlias_TCPUseDynamicTcpPort'
{
Ensure = 'Present'
Name = 'SQLDSC-DYN'
ServerName = 'sqltest.company.local\DSC'
Protocol = 'TCP'
UseDynamicTcpPort = $true
PsDscRunAsCredential = $SqlAdministratorCredential
}
SqlAlias 'Add_SqlAlias_NP'
{
Ensure = 'Present'
Name = 'SQLDSC-NP'
ServerName = '\\sqlnode\PIPE\sql\query'
Protocol = 'NP'
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}
Example 2
This example shows how to ensure that the SQL Alias SQLDSC* does not exist with Named Pipes or TCP.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlAlias 'Remove_SqlAlias_TCP'
{
Ensure = 'Absent'
Name = 'SQLDSC-TCP'
ServerName = 'sqltest.company.local\DSC'
Protocol = 'TCP'
TcpPort = 1777
PsDscRunAsCredential = $SqlAdministratorCredential
}
SqlAlias 'Remove_SqlAlias_NP'
{
Ensure = 'Absent'
Name = 'SQLDSC-NP'
ServerName = '\\sqlnode\PIPE\sql\query'
Protocol = 'NP'
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}