Last active
October 21, 2017 16:48
-
-
Save xsolon/59f091c16dd198e9b2a34132a3620d6c to your computer and use it in GitHub Desktop.
Dsc - Sql Alias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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