Created
December 27, 2015 17:45
-
-
Save MikeFal/df87051e8a8d52740ea8 to your computer and use it in GitHub Desktop.
This file contains 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
#Script Parameters | |
param([string[]]$SqlNodes | |
,[PSCredential]$SetupCredential | |
,[PSCredential]$SqlSvcAccount | |
,[PSCredential]$AgtSvcAccount | |
,[string[]]$SqlAdmins) | |
Configuration SQLServer{ | |
param([string[]] $ComputerName | |
,[PSCredential]$SqlSetupCred | |
,[PSCredential]$SqlSvc | |
,[PSCredential]$AgtSvc | |
,[string[]]$SqlAdmins) | |
#Part of the Microsoft DSC Resource Kit | |
Import-DscResource -Module xNetworking | |
Import-DscResource -Module xSqlServer | |
Import-DscResource –ModuleName 'PSDesiredStateConfiguration' | |
Node $ComputerName { | |
File DataDir{ | |
DestinationPath = 'C:\DBFiles\Data' | |
Type = 'Directory' | |
Ensure = 'Present' | |
} | |
File LogDir{ | |
DestinationPath = 'C:\DBFiles\Log' | |
Type = 'Directory' | |
Ensure = 'Present' | |
} | |
File TempDBDir{ | |
DestinationPath = 'C:\DBFiles\TempDB' | |
Type = 'Directory' | |
Ensure = 'Present' | |
} | |
WindowsFeature NETCore{ | |
Name = 'NET-Framework-Core' | |
Ensure = 'Present' | |
IncludeAllSubFeature = $true | |
Source = 'D:\sources\sxs' | |
} | |
WindowsFeature FC{ | |
Name = 'Failover-Clustering' | |
Ensure = 'Present' | |
Source = 'D:\source\sxs' | |
} | |
xFirewall SQLFW{ | |
Name = 'SQLServer' | |
DisplayName = 'SQL Server' | |
Ensure = 'Present' | |
Profile = 'Domain' | |
Direction = 'Inbound' | |
LocalPort = '1433' | |
Protocol = 'TCP' | |
} | |
xFirewall AGFW{ | |
Name = 'AGEndpoint' | |
DisplayName = 'Availability Group Endpoint' | |
Ensure = 'Present' | |
Profile = 'Domain' | |
Direction = 'Inbound' | |
LocalPort = '5022' | |
Protocol = 'TCP' | |
} | |
xSQLServerSetup SQLInstall{ | |
SourcePath = 'E:\' | |
SetupCredential = $SqlSetupCred | |
Features = 'SQLEngine,FullText' | |
InstanceName = 'MSSQLSERVER' | |
SqlSvcAccount = $Node.SqlSvcAccount | |
AgtSvcAccount = $Node.AgtSvcAccount | |
SqlSysAdminAccounts = $Node.SqlAdminAccounts | |
SQLUserDBDir = 'C:\DBFiles\Data' | |
SQLUserDBLogDir = 'C:\DBFiles\Log' | |
SQLTempDBDir = 'C:\DBFiles\TempDB' | |
SQLTempDBLogDir = 'C:\DBFiles\TempDB' | |
DependsOn = @("[File]DataDir","[File]LogDir","[File]TempDBDir","[WindowsFeature]NETCore") | |
} | |
} | |
} | |
$config = @{AllNodes = @(@{ | |
NodeName = '*'; | |
PSDscAllowPlainTextPassword = $true; | |
PSDscAllowDomainUser = $true; | |
})} | |
If(!(Test-Path 'C:\Temp')){New-Item -ItemType Directory 'C:\Temp'} | |
Set-Location 'C:\Temp' | |
if(Test-Path .\SQLServer){Remove-Item -Recurse .\SQLServer} | |
SqlServer -ComputerName $SqlNodes -SqlSetupCred $SetupCredential -SqlSvc $SqlSvcAccount -AgtSvc $AgtSvcAccount -SqlAdmins $SqlAdmins -ConfigurationData $config | |
Set-DscLocalConfigurationManager -Path .\SQLServer -Verbose | |
Start-DscConfiguration -Path .\SQLServer -Verbose -Force -Wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment