|
| 1 | +<# |
| 2 | + .DESCRIPTION |
| 3 | + This example shows how to install a default instance of SQL Server, and |
| 4 | + Analysis Services in Tabular mode, on a single server. |
| 5 | + It contains configurations that apply to Sql Server 2022 or later only. |
| 6 | +
|
| 7 | + .NOTES |
| 8 | + SQL Server setup is run using the SYSTEM account. Even if SetupCredential is provided |
| 9 | + it is not used to install SQL Server at this time (see issue #139). |
| 10 | +#> |
| 11 | + |
| 12 | +Configuration Example |
| 13 | +{ |
| 14 | + [CmdletBinding()] |
| 15 | + param |
| 16 | + ( |
| 17 | + [Parameter(Mandatory = $true)] |
| 18 | + [ValidateNotNullOrEmpty()] |
| 19 | + [System.Management.Automation.PSCredential] |
| 20 | + $SqlInstallCredential, |
| 21 | + |
| 22 | + [Parameter()] |
| 23 | + [ValidateNotNullOrEmpty()] |
| 24 | + [System.Management.Automation.PSCredential] |
| 25 | + $SqlAdministratorCredential = $SqlInstallCredential, |
| 26 | + |
| 27 | + [Parameter(Mandatory = $true)] |
| 28 | + [ValidateNotNullOrEmpty()] |
| 29 | + [System.Management.Automation.PSCredential] |
| 30 | + $SqlServiceCredential, |
| 31 | + |
| 32 | + [Parameter()] |
| 33 | + [ValidateNotNullOrEmpty()] |
| 34 | + [System.Management.Automation.PSCredential] |
| 35 | + $SqlAgentServiceCredential = $SqlServiceCredential |
| 36 | + ) |
| 37 | + |
| 38 | + Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' -ModuleVersion '9.1.0' |
| 39 | + Import-DscResource -ModuleName 'SqlServerDsc' |
| 40 | + |
| 41 | + node localhost |
| 42 | + { |
| 43 | + #region Install prerequisites for SQL Server |
| 44 | + WindowsFeature 'NetFramework35' |
| 45 | + { |
| 46 | + Name = 'NET-Framework-Core' |
| 47 | + Source = '\\fileserver.company.local\images$\Win2k12R2\Sources\Sxs' # Assumes built-in Everyone has read permission to the share and path. |
| 48 | + Ensure = 'Present' |
| 49 | + } |
| 50 | + |
| 51 | + WindowsFeature 'NetFramework45' |
| 52 | + { |
| 53 | + Name = 'NET-Framework-45-Core' |
| 54 | + Ensure = 'Present' |
| 55 | + } |
| 56 | + #endregion Install prerequisites for SQL Server |
| 57 | + |
| 58 | + #region Install SQL Server |
| 59 | + SqlSetup 'InstallDefaultInstance' |
| 60 | + { |
| 61 | + InstanceName = 'MSSQLSERVER' |
| 62 | + Features = 'SQLENGINE,AS' |
| 63 | + SQLCollation = 'SQL_Latin1_General_CP1_CI_AS' |
| 64 | + SQLSvcAccount = $SqlServiceCredential |
| 65 | + AgtSvcAccount = $SqlAgentServiceCredential |
| 66 | + ASSvcAccount = $SqlServiceCredential |
| 67 | + SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName |
| 68 | + ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName |
| 69 | + InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' |
| 70 | + InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' |
| 71 | + InstanceDir = 'C:\Program Files\Microsoft SQL Server' |
| 72 | + InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' |
| 73 | + SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' |
| 74 | + SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' |
| 75 | + SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' |
| 76 | + SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' |
| 77 | + SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup' |
| 78 | + ASServerMode = 'TABULAR' |
| 79 | + ASConfigDir = 'C:\MSOLAP\Config' |
| 80 | + ASDataDir = 'C:\MSOLAP\Data' |
| 81 | + ASLogDir = 'C:\MSOLAP\Log' |
| 82 | + ASBackupDir = 'C:\MSOLAP\Backup' |
| 83 | + ASTempDir = 'C:\MSOLAP\Temp' |
| 84 | + SourcePath = 'C:\InstallMedia\SQL2016RTM' |
| 85 | + UpdateEnabled = 'False' |
| 86 | + ProductCoveredbySA = $true |
| 87 | + ForceReboot = $false |
| 88 | + SqlTempdbFileCount = 4 |
| 89 | + SqlTempdbFileSize = 1024 |
| 90 | + SqlTempdbFileGrowth = 512 |
| 91 | + SqlTempdbLogFileSize = 128 |
| 92 | + SqlTempdbLogFileGrowth = 64 |
| 93 | + |
| 94 | + PsDscRunAsCredential = $SqlInstallCredential |
| 95 | + |
| 96 | + DependsOn = '[WindowsFeature]NetFramework35', '[WindowsFeature]NetFramework45' |
| 97 | + } |
| 98 | + #endregion Install SQL Server |
| 99 | + } |
| 100 | +} |
0 commit comments