Skip to content

Commit 1ee54b3

Browse files
committedMay 25, 2017
Added SQLServer DSC example
1 parent 6f0a161 commit 1ee54b3

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
 

‎DSC/SQLServer/ConfigurationData.psd1

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@{
2+
AllNodes = @(
3+
@{
4+
NodeName = '*'
5+
PSDscAllowPlainTextPassword = $true
6+
},
7+
@{
8+
NodeName = 'localhost'
9+
}
10+
)
11+
}

‎DSC/SQLServer/SQLServerStandalone.ps1

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#requires -Version 5
2+
3+
Configuration SQLStandalone
4+
{
5+
param(
6+
[pscredential]$SetupCredential ## Need to pass a credential for setup
7+
)
8+
## Download the xSQLServer module from the PowerShell Gallery
9+
Import-DscResource -Module xSQLServer
10+
11+
## Run this DSC configuration on the localhost (gathered from configuration data)
12+
Node $AllNodes.NodeName
13+
{
14+
## Install a prerequisite Windows feature
15+
WindowsFeature "NET-Framework-Core"
16+
{
17+
Ensure = "Present"
18+
Name = "NET-Framework-Core"
19+
Source = "\MEMBERSRV1InstallersWindowsServer2012R2sourcessxs"
20+
}
21+
22+
## Have DSC grab install bits from the SourcePath, install under the instance name with the features
23+
## using the specified SQL Sys admin accounts. Be sure to install the Windows feature first.
24+
xSqlServerSetup 'SqlServerSetup'
25+
{
26+
DependsOn = "[WindowsFeature]NET-Framework-Core"
27+
SourcePath = '\MEMBERSRV1InstallersSqlServer2016'
28+
SetupCredential = $SetupCredential
29+
InstanceName = 'MSSQLSERVER'
30+
Features = 'SQLENGINE,FULLTEXT,RS,AS,IS'
31+
SQLSysAdminAccounts = 'mylab.localAdministrator'
32+
}
33+
34+
## Add firewall exceptions for SQL Server but run SQL server setup first.
35+
xSqlServerFirewall 'SqlFirewall'
36+
{
37+
DependsOn = '[xSqlServerSetup]SqlServerSetup'
38+
SourcePath = '\MEMBERSRV1InstallersSqlServer2016'
39+
InstanceName = 'MSSQLSERVER'
40+
Features = 'SQLENGINE,FULLTEXT,RS,AS,IS'
41+
}
42+
}
43+
}
44+
45+
if (-not (Get-Module -Name xSqlServer -ListAvailable)) {
46+
Install-Module -Name 'xSqlServer' -Confirm:$false
47+
}
48+
49+
SQLStandAlone
50+
Start-DscConfiguration –Wait –Force –Path '.\SQLStandalone' –Verbose

0 commit comments

Comments
 (0)
Please sign in to comment.