dsccommunity / ConfigMgrCBDsc

This module contains DSC resources for the management and configuration of Microsoft System Center Configuration Manager Current Branch (ConfigMgrCB).
MIT License
27 stars 8 forks source link

Two instance so SQL Server Managment Studio #46

Closed PowerShellCrack closed 3 years ago

PowerShellCrack commented 4 years ago

SUGGESTION: When installing SQL 2014; the xSQLSetup installs SSMS feature automatically, yet I can specified a newer one in the params.

No errors in logs, it just has two version installed

image

Suggested solution to the issue

I would change Line 127 to
$Features = 'SQLENGINE,RS,CONN,BC',

Then add right below line 263

if (($SqlVersion -in @('2008', '2008R2','2012','2014')) -and (-Not($InstallManagementStudio)))
    {
        [string]$Features = [string[]]$Features + "SSMS,ADV_SSMS" -join ','
    }

I had to change the $features variable to an array, then join new list, then convert it back to a string to be processed

Or you could put logic to add the built-in SSMS for older SQL versions only if $InstallManagementStudio was specified and only if no additional exe path was specified. Something like:

if (($SqlVersion -in @('2008', '2008R2','2012','2014')) -and ($InstallManagementStudio) -and ($null -eq $SqlManagementStudioExePath))
    {
        [string]$Features = [string[]]$Features + "SSMS,ADV_SSMS" -join ','
    }

Then in line 304 where is checking for the path, change it to:

if (($SqlVersion -notin @('2008', '2008R2','2012','2014')) -and ($null -eq $SqlManagementStudioExePath))
        {
            Write-Error -Message $('When specifying to Install SQL Management Studio, you need to provide ' +
                'SqlManagementStudioExePath.')
        }

this will ensure that the config is checking the sql versions and why or why path is missing for only the higher versions

The DSC configuration that is used

xSccmSqlSetup SQLInstall
        {
            SqlVersion                  = '2014'
            SqlInstanceName             = 'MSSQLSERVER'
            SqlServiceCredential        = $sqlcreds
            SqlAgentServiceCredential   = $sqlcreds
            SqlSysAdminAccounts         = @($sqlUsername,$cmUsername)
            SqlInstallPath              = "U:\SQL2014SP3CU4_ENU\"
            InstallSqlDataDir           = 'E:\Microsoft SQL Server'
            SQLUserDBDir                = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data'
            SQLUserDBLogDir             = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log'
            SQLTempDBDir                = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Temp'
            SQLTempDBLogDir             = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log'
            UpdateEnabled               = $true
            InstallManagementStudio     = $true
            SqlManagementStudioExePath  = "U:\SSMS_18.5\SSMS-Setup-ENU.exe"
            SqlManagemenStudioProductId = '061E40C6-EFF2-482A-82BC-B0A0FDC47898'
            PsDscRunAsCredential        = $sqlcreds
            DependsOn                   = '[xSccmPreReqs]CASprereqs'
        }  

The operating system the target node is running

OsName : Microsoft Windows Server 2012 R2 Standard OsOperatingSystemSKU : StandardServerEdition OsArchitecture : 64-bit WindowsBuildLabEx : 9600.19724.amd64fre.winblue_ltsb_escrow.200519-1914 OsLanguage : en-US OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

Key : PSVersion Value : 5.1.14409.1018 Name : PSVersion

Key : PSEdition Value : Desktop Name : PSEdition

Key : PSCompatibleVersions Value : {1.0, 2.0, 3.0, 4.0...} Name : PSCompatibleVersions

Key : BuildVersion Value : 10.0.14409.1018 Name : BuildVersion

Key : CLRVersion Value : 4.0.30319.42000 Name : CLRVersion

Key : WSManStackVersion Value : 3.0 Name : WSManStackVersion

Key : PSRemotingProtocolVersion Value : 2.3 Name : PSRemotingProtocolVersion

Key : SerializationVersion Value : 1.1.0.1 Name : SerializationVersion

Version of the DSC module that was used

0.2.0

rchristman89 commented 4 years ago

@PowerShellCrack You can change following but by providing the Features to the composite resource:

xSccmSqlSetup SQLInstall
        {
            SqlVersion                  = '2014'
            SqlInstanceName             = 'MSSQLSERVER'
            SqlServiceCredential        = $sqlcreds
            SqlAgentServiceCredential   = $sqlcreds
            SqlSysAdminAccounts         = @($sqlUsername,$cmUsername)
            SqlInstallPath              = "U:\SQL2014SP3CU4_ENU\"
            InstallSqlDataDir           = 'E:\Microsoft SQL Server'
            SQLUserDBDir                = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data'
            SQLUserDBLogDir             = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log'
            SQLTempDBDir                = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Temp'
            SQLTempDBLogDir             = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log'
            UpdateEnabled               = $true
            InstallManagementStudio     = $true
            SqlManagementStudioExePath  = "U:\SSMS_18.5\SSMS-Setup-ENU.exe"
            SqlManagemenStudioProductId = '061E40C6-EFF2-482A-82BC-B0A0FDC47898'
            PsDscRunAsCredential        = $sqlcreds
            DependsOn                   = '[xSccmPreReqs]CASprereqs'
        }  

to

xSccmSqlSetup SQLInstall
        {
            SqlVersion                  = '2014'
            SqlInstanceName             = 'MSSQLSERVER'
            Features                    = 'SQLENGINE,RS,CONN,BC'
            SqlServiceCredential        = $sqlcreds
            SqlAgentServiceCredential   = $sqlcreds
            SqlSysAdminAccounts         = @($sqlUsername,$cmUsername)
            SqlInstallPath              = "U:\SQL2014SP3CU4_ENU\"
            InstallSqlDataDir           = 'E:\Microsoft SQL Server'
            SQLUserDBDir                = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data'
            SQLUserDBLogDir             = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log'
            SQLTempDBDir                = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Temp'
            SQLTempDBLogDir             = 'E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log'
            UpdateEnabled               = $true
            InstallManagementStudio     = $true
            SqlManagementStudioExePath  = "U:\SSMS_18.5\SSMS-Setup-ENU.exe"
            SqlManagemenStudioProductId = '061E40C6-EFF2-482A-82BC-B0A0FDC47898'
            PsDscRunAsCredential        = $sqlcreds
            DependsOn                   = '[xSccmPreReqs]CASprereqs'
        }