Skip to content

Instantly share code, notes, and snippets.

@xsolon
Last active October 21, 2017 16:48
Show Gist options
  • Save xsolon/59f091c16dd198e9b2a34132a3620d6c to your computer and use it in GitHub Desktop.
Save xsolon/59f091c16dd198e9b2a34132a3620d6c to your computer and use it in GitHub Desktop.
Dsc - Sql Alias
#Install-PackageProvider -Name Nuget -MinimumVersion 2.8.5.201
Configuration sqlAlias
{
Import-Module PSDesiredStateConfiguration -ErrorAction SilentlyContinue
Import-Module xSQLServer -ErrorAction SilentlyContinue
if ((get-module -Name PSDesiredStateConfiguration) -eq $null){
Install-Module PSDesiredStateConfiguration -Force
Import-Module PSDesiredStateConfiguration
}
if ((get-module -Name xSQLServer) -eq $null){
Install-Module xSQLServer -Force
Import-Module xSQLServer
}
Import-DscResource -ModuleName xSqlServer
node $env:ComputerName {
xSQLServerAlias Add_SqlAlias_TCP
{
Ensure = 'Present'
Name = 'sql'
ServerName = "servername"
Protocol = 'TCP'
TcpPort = 1433
#PsDscRunAsCredential = $SysAdminAccount
}
}
}
sqlAlias
Start-DSCConfiguration -ComputerName $env:ComputerName -Path .\sqlAlias -Wait -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment