diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d2f04a99..44fc2fce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SqlServerDsc - Added build tasks to generate Wiki documentation for public commands. + - Initial integration tests for commands. - SqlDatabaseMail - Added the parameter `UseDefaultCredentials` to control use of the DatabaseEngine service account for SMTP server authentication. +- New public commands + - `Save-SqlDscSqlServerMediaFile` - Downloads the content on the provided URL + and if it is an executable it will use the executable to download the + ISO image media. ### Fixed @@ -35,6 +40,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - New method ToString() for making verbose output better. - SqlAgDatabase - Remove unused help file ([issue #1745](https://github.com/dsccommunity/SqlServerDsc/issues/1745)). +- `Install-SqlDscServer` + - No longer throws with duplicate parameter error if the parameter + `ErrorAction` is passed to the command. +- `Add-SqlDscNode` + - No longer throws with duplicate parameter error if the parameter + `ErrorAction` is passed to the command. +- `Complete-SqlDscFailoverCluster` + - No longer throws with duplicate parameter error if the parameter + `ErrorAction` is passed to the command. +- `Complete-SqlDscImage` + - No longer throws with duplicate parameter error if the parameter + `ErrorAction` is passed to the command. +- `Initialize-SqlDscRebuildDatabase` + - No longer throws with duplicate parameter error if the parameter + `ErrorAction` is passed to the command. +- `Remove-SqlDscNode` + - No longer throws with duplicate parameter error if the parameter + `ErrorAction` is passed to the command. +- `Repair-SqlDscServer` + - No longer throws with duplicate parameter error if the parameter + `ErrorAction` is passed to the command. +- `Uninstall-SqlDscServer` + - No longer throws with duplicate parameter error if the parameter + `ErrorAction` is passed to the command. +- Private functions + - `Invoke-SetupAction` no longer throws when secure strings is passed on + Windows PowerShell. ### Changed diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ff3ab3306..a52097334 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -235,6 +235,13 @@ stages: buildType: 'current' artifactName: $(buildArtifactName) targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false - powershell: | Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') @@ -244,9 +251,10 @@ stages: - powershell: | ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( # Run the integration tests in a specific group order. + # Group 0 + 'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1' # Group 1 'tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1' - # Group 2 #'tests/Integration/Commands/Install-SqlDscReportingServices.Integration.Tests.ps1' ) name: test diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 5a18c3a89..d92ca10e5 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -569,9 +569,9 @@ function Connect-SQL $sqlConnectionContext.Connect() <# - The addition of the ConnetTimeout property to the ConnectionContext will force the + The addition of the ConnectTimeout property to the ConnectionContext will force the Connect() method to block until successful. THe SMO object's Status property may not - report 'Online' immediately eventhough the Connect() was successful. The loop is to + report 'Online' immediately even though the Connect() was successful. The loop is to ensure the SMO's Status property was been updated. #> $sleepInSeconds = 2 diff --git a/source/Private/Invoke-SetupAction.ps1 b/source/Private/Invoke-SetupAction.ps1 index a71a17510..f242fbb94 100644 --- a/source/Private/Invoke-SetupAction.ps1 +++ b/source/Private/Invoke-SetupAction.ps1 @@ -465,7 +465,7 @@ #> function Invoke-SetupAction { - # cSpell: ignore PBDMS Admini AZUREEXTENSION + # cSpell: ignore PBDMS Admini AZUREEXTENSION BSTR [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] [OutputType()] param @@ -1618,7 +1618,18 @@ function Invoke-SetupAction { $PSBoundParameters.$parameterName -is [System.Security.SecureString] } { - $passwordClearText = $PSBoundParameters.$parameterName | ConvertFrom-SecureString -AsPlainText + $secureString = $PSBoundParameters.$parameterName + + if ($PSVersionTable.PSVersion -ge '6.0') + { + $passwordClearText = $secureString | ConvertFrom-SecureString -AsPlainText + } + else + { + # Workaround to convert SecureString to plain text in Windows PowerShell. + $binaryStringPointer = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureString) + $passwordClearText = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($binaryStringPointer) + } $sensitiveValue += $passwordClearText diff --git a/source/Public/Add-SqlDscNode.ps1 b/source/Public/Add-SqlDscNode.ps1 index 810f696ae..a3074fd10 100644 --- a/source/Public/Add-SqlDscNode.ps1 +++ b/source/Public/Add-SqlDscNode.ps1 @@ -252,5 +252,5 @@ function Add-SqlDscNode $Force ) - Invoke-SetupAction -AddNode @PSBoundParameters -ErrorAction 'Stop' + Invoke-SetupAction -AddNode @PSBoundParameters } diff --git a/source/Public/Complete-SqlDscFailoverCluster.ps1 b/source/Public/Complete-SqlDscFailoverCluster.ps1 index 41ab66f19..77128130e 100644 --- a/source/Public/Complete-SqlDscFailoverCluster.ps1 +++ b/source/Public/Complete-SqlDscFailoverCluster.ps1 @@ -306,5 +306,5 @@ function Complete-SqlDscFailoverCluster $Force ) - Invoke-SetupAction -CompleteFailoverCluster @PSBoundParameters -ErrorAction 'Stop' + Invoke-SetupAction -CompleteFailoverCluster @PSBoundParameters } diff --git a/source/Public/Complete-SqlDscImage.ps1 b/source/Public/Complete-SqlDscImage.ps1 index 17b32d873..2c37dffd8 100644 --- a/source/Public/Complete-SqlDscImage.ps1 +++ b/source/Public/Complete-SqlDscImage.ps1 @@ -375,5 +375,5 @@ function Complete-SqlDscImage $Force ) - Invoke-SetupAction -CompleteImage @PSBoundParameters -ErrorAction 'Stop' + Invoke-SetupAction -CompleteImage @PSBoundParameters } diff --git a/source/Public/Initialize-SqlDscRebuildDatabase.ps1 b/source/Public/Initialize-SqlDscRebuildDatabase.ps1 index 4a0af444a..a10eb3e27 100644 --- a/source/Public/Initialize-SqlDscRebuildDatabase.ps1 +++ b/source/Public/Initialize-SqlDscRebuildDatabase.ps1 @@ -141,5 +141,5 @@ function Initialize-SqlDscRebuildDatabase $Force ) - Invoke-SetupAction -RebuildDatabase @PSBoundParameters -ErrorAction 'Stop' + Invoke-SetupAction -RebuildDatabase @PSBoundParameters } diff --git a/source/Public/Install-SqlDscServer.ps1 b/source/Public/Install-SqlDscServer.ps1 index ba2923ab2..19e723136 100644 --- a/source/Public/Install-SqlDscServer.ps1 +++ b/source/Public/Install-SqlDscServer.ps1 @@ -1139,5 +1139,5 @@ function Install-SqlDscServer $Force ) - Invoke-SetupAction @PSBoundParameters -ErrorAction 'Stop' + Invoke-SetupAction @PSBoundParameters } diff --git a/source/Public/Remove-SqlDscNode.ps1 b/source/Public/Remove-SqlDscNode.ps1 index 98911774c..af6cc56e7 100644 --- a/source/Public/Remove-SqlDscNode.ps1 +++ b/source/Public/Remove-SqlDscNode.ps1 @@ -73,5 +73,5 @@ function Remove-SqlDscNode $Force ) - Invoke-SetupAction -RemoveNode @PSBoundParameters -ErrorAction 'Stop' + Invoke-SetupAction -RemoveNode @PSBoundParameters } diff --git a/source/Public/Repair-SqlDscServer.ps1 b/source/Public/Repair-SqlDscServer.ps1 index 811bbcc95..62f5dbf33 100644 --- a/source/Public/Repair-SqlDscServer.ps1 +++ b/source/Public/Repair-SqlDscServer.ps1 @@ -156,5 +156,5 @@ function Repair-SqlDscServer $Force ) - Invoke-SetupAction -Repair @PSBoundParameters -ErrorAction 'Stop' + Invoke-SetupAction -Repair @PSBoundParameters } diff --git a/source/Public/Save-SqlDscSqlServerMediaFile.ps1 b/source/Public/Save-SqlDscSqlServerMediaFile.ps1 new file mode 100644 index 000000000..eb88325ff --- /dev/null +++ b/source/Public/Save-SqlDscSqlServerMediaFile.ps1 @@ -0,0 +1,228 @@ +<# + .SYNOPSIS + Downloads SQL Server media from a provided URL and saves the downloaded + media file to the specified file path + + .DESCRIPTION + The Save-SqlDscSqlServerMediaFile function downloads SQL Server media from a + provided URL and saves the downloaded media file to the specified file path. + + If the URL ends with ".exe", it is treated as an executable that downloads + an ISO. If it doesn't, it is treated as a direct link to an ISO. + + The function also prints the SHA1 hash of the downloaded file. + + .PARAMETER Url + The URL of the SQL Server media to download. + + .PARAMETER DestinationPath + The file path where the downloaded media file should be saved. + + .PARAMETER FileName + The file name of the downloaded media file. Defaults to media.iso if not + provided. + + .PARAMETER Language + The language parameter specifies the language of the downloaded iso. This + parameter is only used when the provided URL is an executable file. Defaults + to 'en-US' if not provided. + + .PARAMETER Quiet + Disables verbose progress output during the download process. + + .PARAMETER Force + Forces the download of the media file even if the file already exists at the + specified destination path. + + .EXAMPLE + Save-SqlDscSqlServerMediaFile -Url 'https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe' -DestinationPath 'C:\path\to\destination' + + This downloads the SQL Server 2022 media and saves it to the specified destination path. + + .EXAMPLE + Save-SqlDscSqlServerMediaFile -Url 'https://download.microsoft.com/download/d/a/2/da259851-b941-459d-989c-54a18a5d44dd/SQL2019-SSEI-Dev.exe' -DestinationPath 'C:\path\to\destination' + + This downloads the SQL Server 2019 media and saves it to the specified destination path. + + .EXAMPLE + Save-SqlDscSqlServerMediaFile -Url 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLServer2017-x64-ENU.iso' -DestinationPath 'C:\path\to\destination' + + This downloads the SQL Server 2017 media and saves it to the specified destination path. + + .EXAMPLE + Save-SqlDscSqlServerMediaFile -Url 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLServer2016SP1-FullSlipstream-x64-ENU.iso' -DestinationPath 'C:\path\to\destination' + + This downloads the SQL Server 2016 media and saves it to the specified destination path. +#> +function Save-SqlDscSqlServerMediaFile +{ + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + [OutputType([System.IO.FileInfo])] + param + ( + [Parameter(Mandatory = $true)] + [System.String] + $Url, + + [Parameter(Mandatory = $true)] + [System.IO.FileInfo] + [ValidateScript({ Test-Path $_ -PathType 'Container' })] + $DestinationPath, + + [Parameter()] + [System.String] + $FileName = 'media.iso', + + [Parameter()] + # Supported by SQL Server version 2019 and 2022. + [ValidateSet('zh-CN', 'zh-TW', 'en-US', 'fr-FR', 'de-DE', 'it-IT', 'ja-JP', 'ko-KR', 'pt-BR', 'ru-RU', 'es-ES')] + [System.String] + $Language = 'en-US', + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $Quiet, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $Force + ) + + if ($Force.IsPresent -and -not $Confirm) + { + $ConfirmPreference = 'None' + } + + if ((Get-Item -Path "$DestinationPath/*.iso" -Force).Count -gt 0) + { + $auditAlreadyPresentMessage = $script:localizedData.SqlServerMediaFile_Save_InvalidDestinationFolder + + $PSCmdlet.ThrowTerminatingError( + [System.Management.Automation.ErrorRecord]::new( + $auditAlreadyPresentMessage, + 'SSDSSM0001', # cspell: disable-line + [System.Management.Automation.ErrorCategory]::InvalidOperation, + $DestinationPath + ) + ) + } + + $destinationFilePath = Join-Path -Path $DestinationPath -ChildPath $FileName + + if ((Test-Path -Path $destinationFilePath)) + { + $verboseDescriptionMessage = $script:localizedData.SqlServerMediaFile_Save_ShouldProcessVerboseDescription -f $destinationFilePath + $verboseWarningMessage = $script:localizedData.qlServerMedia_Save_ShouldProcessVerboseWarning -f $destinationFilePath + $captionMessage = $script:localizedData.qlServerMedia_Save_ShouldProcessCaption + + if ($PSCmdlet.ShouldProcess($verboseDescriptionMessage, $verboseWarningMessage, $captionMessage)) + { + Remove-Item -Path $destinationFilePath -Force + } + else + { + return + } + } + + Write-Verbose -Message ($script:localizedData.SqlServerMediaFile_Save_ShouldProcessVerboseDescription -f $destinationFilePath) + + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + + $isExecutable = $false + + if ($Url -match '\.exe$') + { + $isExecutable = $true + + # Change the file extension of the destination file path to .exe + $destinationExecutableFilePath = [System.IO.Path]::ChangeExtension($destinationFilePath, 'exe') + + $downloadedFilePath = $destinationExecutableFilePath + } + else + { + $downloadedFilePath = $destinationFilePath + } + + if ($Quiet.IsPresent) + { + <# + By switching to 'SilentlyContinue' it removes the progress bar of + Invoke-WebRequest and should also theoretically increase the download + speed. + #> + $previousProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' + } + + # Download the URL content. + Invoke-WebRequest -Uri $Url -OutFile $downloadedFilePath | Out-Null + + if ($Quiet.IsPresent) + { + # Revert the progress preference back to the previous value. + $ProgressPreference = $previousProgressPreference + } + + if ($isExecutable) + { + Write-Verbose -Message $script:localizedData.SqlServerMediaFile_Save_IsExecutable + + $executableArguments = @( + '/Quiet' + ) + + if ($VerbosePreference -eq 'SilentlyContinue') + { + $executableArguments += @( + '/HideProgressBar' + ) + } + else + { + $executableArguments += @( + '/Verbose' + ) + } + + $executableArguments += @( + '/Action=Download', + "/Language=$Language", + '/MediaType=ISO', + "/MediaPath=$destinationPath" + ) + + $startProcessArgumentList = $executableArguments -join ' ' + + # Download ISO media using the downloaded executable. + Start-Process -FilePath $destinationExecutableFilePath -ArgumentList $startProcessArgumentList -Wait + + Write-Verbose -Message $script:localizedData.SqlServerMediaFile_Save_RemovingExecutable + + # Remove the downloaded executable. + Remove-Item -Path $destinationExecutableFilePath -Force + + # Get all the iso files in the destination path and if there are more than one throw an error. + $isoFile = Get-Item -Path "$DestinationPath/*.iso" -Force + + if ($isoFile.Count -gt 1) + { + $writeErrorParameters = @{ + Message = $script:localizedData.SqlServerMediaFile_Save_MultipleFilesFoundAfterDownload + Category = 'InvalidOperation' + ErrorId = 'SSDSSM0002' # CSpell: disable-line + TargetObject = $ServiceType + } + + Write-Error @writeErrorParameters + } + + Write-Verbose -Message ($script:localizedData.SqlServerMediaFile_Save_RenamingFile -f $isoFile.Name, $FileName) + + # Rename the iso file in the destination path. + Rename-Item -Path $isoFile.FullName -NewName $FileName -Force + } + + return (Get-Item -Path $destinationFilePath) +} diff --git a/source/Public/Uninstall-SqlDscServer.ps1 b/source/Public/Uninstall-SqlDscServer.ps1 index bb336d42c..59e3984e5 100644 --- a/source/Public/Uninstall-SqlDscServer.ps1 +++ b/source/Public/Uninstall-SqlDscServer.ps1 @@ -114,5 +114,5 @@ function Uninstall-SqlDscServer $SuppressPrivacyStatementNotice ) - Invoke-SetupAction -Uninstall @PSBoundParameters -ErrorAction 'Stop' + Invoke-SetupAction -Uninstall @PSBoundParameters } diff --git a/source/en-US/SqlServerDsc.strings.psd1 b/source/en-US/SqlServerDsc.strings.psd1 index 07e5bf4c5..3a3554a8b 100644 --- a/source/en-US/SqlServerDsc.strings.psd1 +++ b/source/en-US/SqlServerDsc.strings.psd1 @@ -150,7 +150,7 @@ ConvertFrom-StringData @' ## Get-SqlDscPreferredModule PreferredModule_ModuleVersionFound = Preferred module '{0}' with version '{1}' found. PreferredModule_ModuleNotFound = No preferred PowerShell module was found. -PreferredModule_ModuleVersionNotFound = No preferred Powershell module with version '{0}' was found. + PreferredModule_ModuleVersionNotFound = No preferred Powershell module with version '{0}' was found. ## Import-SqlDscPreferredModule PreferredModule_ImportedModule = Imported PowerShell module '{0}' with version '{1}' from path '{2}'. @@ -182,4 +182,16 @@ PreferredModule_ModuleVersionNotFound = No preferred Powershell module with vers ## Get-SqlDscConfigurationOption ConfigurationOption_Get_Missing = There is no configuration option with the name '{0}'. + + ## Save-SqlDscSqlServerMediaFile + SqlServerMediaFile_Save_ShouldProcessVerboseDescription = The existing destination file '{0}' already exists and will be replaced. + SqlServerMediaFile_Save_ShouldProcessVerboseWarning = Are you sure you want to replace existing file '{0}'? + # This string shall not end with full stop (.) since it is used as a title of ShouldProcess messages. + SqlServerMediaFile_Save_ShouldProcessCaption = Replace existing file + SqlServerMediaFile_Save_InvalidDestinationFolder = Multiple files with the .iso extension was found in the destination path. Please choose another destination folder. + SqlServerMediaFile_Save_MultipleFilesFoundAfterDownload = Multiple files with the .iso extension was found in the destination path. Cannot determine which one of the files that was downloaded. + SqlServerMediaFile_Save_DownloadingInformation = Downloading the SQL Server media from '{0}'. + SqlServerMediaFile_Save_IsExecutable = Downloaded an executable file. Using the executable to download the media file. + SqlServerMediaFile_Save_RemovingExecutable = Removing the downloaded executable file. + SqlServerMediaFile_Save_RenamingFile = Renaming the downloaded file from '{0}' to '{1}'. '@ diff --git a/tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1 b/tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1 index ddb0517f7..f14b2c486 100644 --- a/tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1 +++ b/tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1 @@ -24,25 +24,176 @@ BeforeDiscovery { } Describe 'Install-SqlDscServer' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { + # BeforeAll { + # # Get the built SqlServerDsc module path. + # $modulePath = Split-Path -Parent -Path (Get-Module -name SqlServerDsc -ListAvailable).ModuleBase + # } + Context 'When using Install parameter set' { Context 'When installing database engine default instance' { It 'Should run the command without throwing' { { + Write-Verbose -Message ('Running install as user ''{0}''.' -f $env:UserName) -Verbose + + $computerName = Get-ComputerName + # Set splatting parameters for Install-SqlDscServer $installSqlDscServerParameters = @{ - Install = $true - AcceptLicensingTerms = $true - InstanceName = 'MSSQLSERVER' - Features = 'SQLENGINE' - SqlSysAdminAccounts = @('MyAdminAccount') - MediaPath = 'E:\' - Verbose = $true - ErrorAction = 'Stop' + Install = $true + AcceptLicensingTerms = $true + InstanceName = 'MSSQLSERVER' + Features = 'SQLENGINE' + SqlSysAdminAccounts = @( + ('{0}\SqlAdmin' -f $computerName) + ) + SqlSvcAccount = '{0}\svc-SqlPrimary' -f $computerName + SqlSvcPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force + SqlSvcStartupType = 'Automatic' + AgtSvcAccount = '{0}\svc-SqlAgentPri' -f $computerName + AgtSvcPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force + AgtSvcStartupType = 'Automatic' + BrowserSvcStartupType = 'Automatic' + SecurityMode = 'SQL' + SAPwd = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force + SqlCollation = 'Finnish_Swedish_CI_AS' + InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' + InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' + MediaPath = $env:IsoDrivePath + Verbose = $true + ErrorAction = 'Stop' + Force = $true } - # Install-SqlDscServer @installSqlDscServerParameters + Install-SqlDscServer @installSqlDscServerParameters + + # <# + # Fails with the following error message: + + # VERBOSE: Exit code (Decimal): -2068774911 + # VERBOSE: Exit facility code: 1201 + # VERBOSE: Exit error code: 1 + # VERBOSE: Exit message: There was an error generating the XML document. + + # Searches points to a permission issue, but the user has been + # granted the local administrator permissions. But code be + # Searches also points to user right SeEnableDelegationPrivilege + # which was not evaluated if it was set correctly or even needed. + # #> + # $installScriptBlock = { + # param + # ( + # [Parameter(Mandatory = $true)] + # [System.String] + # $IsoDrivePath, + + # [Parameter(Mandatory = $true)] + # [System.String] + # $ComputerName, + + # [Parameter(Mandatory = $true)] + # [System.String] + # $ModulePath + # ) + + # Write-Verbose -Message ('Running install as user ''{0}''.' -f $env:UserName) -Verbose + + # Import-Module -Name $ModulePath -Force -ErrorAction 'Stop' + + # # Set splatting parameters for Install-SqlDscServer + # $installSqlDscServerParameters = @{ + # Install = $true + # AcceptLicensingTerms = $true + # InstanceName = 'MSSQLSERVER' + # Features = 'SQLENGINE' + # SqlSysAdminAccounts = @( + # ('{0}\SqlAdmin' -f $ComputerName) + # ) + # SqlSvcAccount = '{0}\svc-SqlPrimary' -f $ComputerName + # SqlSvcPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force + # SqlSvcStartupType = 'Automatic' + # AgtSvcAccount = '{0}\svc-SqlAgentPri' -f $ComputerName + # AgtSvcPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force + # AgtSvcStartupType = 'Automatic' + # BrowserSvcStartupType = 'Automatic' + # SecurityMode = 'SQL' + # SAPwd = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force + # SqlCollation = 'Finnish_Swedish_CI_AS' + # InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' + # InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' + # MediaPath = $IsoDrivePath + # Verbose = $true + # ErrorAction = 'Stop' + # Force = $true + # } + + # Install-SqlDscServer @installSqlDscServerParameters + # } + + # $invokeCommandUsername = '{0}\SqlInstall' -f $ComputerName + # $invokeCommandPassword = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force + # $invokeCommandCredential = New-Object System.Management.Automation.PSCredential ($invokeCommandUsername, $invokeCommandPassword) + + # # Runs command as SqlInstall user. + # Invoke-Command -ComputerName 'localhost' -Credential $invokeCommandCredential -ScriptBlock $installScriptBlock -ArgumentList @( + # $env:IsoDrivePath, # Already set by the prerequisites tests + # (Get-ComputerName), + # $modulePath + # ) } | Should -Not -Throw } + + It 'Should have installed the SQL Server database engine' { + # Validate the SQL Server installation + $sqlServerService = Get-Service -Name 'MSSQLSERVER' + + $sqlServerService | Should -Not -BeNullOrEmpty + $sqlServerService.Status | Should -Be 'Running' + } } + + # Context 'Output the Summary.txt log file' { + # BeforeAll { + # <# + # .SYNOPSIS + # This function will output the Setup Bootstrap Summary.txt log file. + + # .DESCRIPTION + # This function will output the Summary.txt log file, this is to be + # able to debug any problems that potentially occurred during setup. + # This will pick up the newest Summary.txt log file, so any + # other log files will be ignored (AppVeyor build worker has + # SQL Server instances installed by default). + # This code is meant to work regardless what SQL Server + # major version is used for the integration test. + # #> + # function Show-SqlBootstrapLog + # { + # [CmdletBinding()] + # param + # ( + # ) + + # $summaryLogPath = Get-ChildItem -Path 'C:\Program Files\Microsoft SQL Server\**\Setup Bootstrap\Log\Summary.txt' | + # Sort-Object -Property LastWriteTime -Descending | + # Select-Object -First 1 + + # $summaryLog = Get-Content $summaryLogPath + + # Write-Verbose -Message $('-' * 80) -Verbose + # Write-Verbose -Message 'Summary.txt' -Verbose + # Write-Verbose -Message $('-' * 80) -Verbose + + # $summaryLog | ForEach-Object -Process { + # Write-Verbose $_ -Verbose + # } + + # Write-Verbose -Message $('-' * 80) -Verbose + # } + # } + + # It 'Should output the Summary.txt log file' { + # Show-SqlBootstrapLog + # } + # } } } diff --git a/tests/Integration/Commands/Prerequisites.Integration.Tests.ps1 b/tests/Integration/Commands/Prerequisites.Integration.Tests.ps1 new file mode 100644 index 000000000..3dac6db6e --- /dev/null +++ b/tests/Integration/Commands/Prerequisites.Integration.Tests.ps1 @@ -0,0 +1,205 @@ +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] +param () + +BeforeDiscovery { + try + { + if (-not (Get-Module -Name 'DscResource.Test')) + { + # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) + { + # Redirect all streams to $null, except the error stream (stream 2) + & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 2>&1 4>&1 5>&1 6>&1 > $null + } + + # If the dependencies has not been resolved, this will throw an error. + Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' + } + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.' + } +} + +# CSpell: ignore Remoting +Describe 'Prerequisites' { + Context 'Create required local Windows users' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { + BeforeAll { + $password = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force + } + + It 'Should create SqlInstall user' { + $user = New-LocalUser -Name 'SqlInstall' -Password $password -FullName 'SQL Install User' -Description 'User for SQL installation.' + + $user.Name | Should -Be 'SqlInstall' + (Get-LocalUser -Name 'SqlInstall').Name | Should -Be 'SqlInstall' + } + + It 'Should create SqlAdmin user' { + $user = New-LocalUser -Name 'SqlAdmin' -Password $password -FullName 'SQL Admin User' -Description 'User for SQL administration.' + + $user.Name | Should -Be 'SqlAdmin' + (Get-LocalUser -Name 'SqlAdmin').Name | Should -Be 'SqlAdmin' + } + } + + Context 'Should create required local Windows service accounts' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { + BeforeAll { + $password = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force + } + + It 'Should create svc-SqlPrimary user' { + $user = New-LocalUser -Name 'svc-SqlPrimary' -Password $password -FullName 'svc-SqlPrimary' -Description 'Runs the SQL Server service.' + + $user.Name | Should -Be 'svc-SqlPrimary' + (Get-LocalUser -Name 'svc-SqlPrimary').Name | Should -Be 'svc-SqlPrimary' + } + + It 'Should create svc-SqlAgentPri user' { + $user = New-LocalUser -Name 'svc-SqlAgentPri' -Password $password -FullName 'svc-SqlAgentPri' -Description 'Runs the SQL Server Agent service.' + + $user.Name | Should -Be 'svc-SqlAgentPri' + (Get-LocalUser -Name 'svc-SqlAgentPri').Name | Should -Be 'svc-SqlAgentPri' + } + + It 'Should create svc-SqlSecondary user' { + $user = New-LocalUser -Name 'svc-SqlSecondary' -Password $password -FullName 'svc-SqlSecondary' -Description 'Runs the SQL Server service.' + + $user.Name | Should -Be 'svc-SqlSecondary' + (Get-LocalUser -Name 'svc-SqlSecondary').Name | Should -Be 'svc-SqlSecondary' + } + + It 'Should create svc-SqlAgentSec user' { + $user = New-LocalUser -Name 'svc-SqlAgentSec' -Password $password -FullName 'svc-SqlAgentSec' -Description 'Runs the SQL Server Agent service.' + + $user.Name | Should -Be 'svc-SqlAgentSec' + (Get-LocalUser -Name 'svc-SqlAgentSec').Name | Should -Be 'svc-SqlAgentSec' + } + } + + Context 'Add local Windows users to local groups' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { + It 'Should add SqlInstall to local administrator group' { + # Add user to local administrator group + Add-LocalGroupMember -Group 'Administrators' -Member 'SqlInstall' + + # Verify if user is part of local administrator group + $adminGroup = Get-LocalGroup -Name 'Administrators' + $adminGroupMembers = Get-LocalGroupMember -Group $adminGroup + $adminGroupMembers.Name | Should -Contain ('{0}\SqlInstall' -f (Get-ComputerName)) + } + } + + Context 'Download correct SQL Server media' { + It 'Should download SQL Server 2016 media' -Tag @('Integration_SQL2016') { + $url = 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLServer2016SP1-FullSlipstream-x64-ENU.iso' + + $script:mediaFile = Save-SqlDscSqlServerMediaFile -Url $url -DestinationPath $env:TEMP -Force -Quiet -ErrorAction 'Stop' + + $mediaFile.Name | Should -Be 'media.iso' + } + + It 'Should download SQL Server 2017 media' -Tag @('Integration_SQL2017') { + $url = 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLServer2017-x64-ENU.iso' + + $script:mediaFile = Save-SqlDscSqlServerMediaFile -Url $url -DestinationPath $env:TEMP -Force -Quiet -ErrorAction 'Stop' + + $mediaFile.Name | Should -Be 'media.iso' + } + + It 'Should download SQL Server 2019 media' -Tag @('Integration_SQL2019') { + $url = 'https://download.microsoft.com/download/d/a/2/da259851-b941-459d-989c-54a18a5d44dd/SQL2019-SSEI-Dev.exe' + + $script:mediaFile = Save-SqlDscSqlServerMediaFile -Url $url -DestinationPath $env:TEMP -Force -Quiet -ErrorAction 'Stop' + + $mediaFile.Name | Should -Be 'media.iso' + } + + It 'Should download SQL Server 2022 media' -Tag @('Integration_SQL2022') { + $url = 'https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe' + + $script:mediaFile = Save-SqlDscSqlServerMediaFile -Url $url -DestinationPath $env:TEMP -Force -Quiet -ErrorAction 'Stop' + + $mediaFile.Name | Should -Be 'media.iso' + } + } + + Context 'Mount SQL Server media' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { + It 'Should mount the media to a drive letter' { + $mountedImage = Mount-DiskImage -ImagePath $script:mediaFile + $mountedImage | Should -BeOfType 'Microsoft.Management.Infrastructure.CimInstance' + + $mountedVolume = Get-Volume -DiskImage $mountedImage + $mountedVolume.DriveLetter | Should -Not -BeNullOrEmpty + + $env:IsoDriveLetter = $mountedVolume.DriveLetter + $env:IsoDriveLetter | Should -Not -BeNullOrEmpty + + $env:IsoDrivePath = (Get-PSDrive -Name $env:IsoDriveLetter).Root + $env:IsoDrivePath | Should -Be ('{0}:\' -f $env:IsoDriveLetter) + } + + It 'Should have set environment variable for drive letter' { + $env:IsoDriveLetter | Should -Not -BeNullOrEmpty + } + + It 'Should have set environment variable for drive path' { + $env:IsoDrivePath | Should -Be ('{0}:\' -f $env:IsoDriveLetter) + } + } + + Context 'Install correct version of module SqlServer' { + It 'Should have the minimum required version of Microsoft.PowerShell.PSResourceGet' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { + $module = Get-Module -Name 'Microsoft.PowerShell.PSResourceGet' -ListAvailable + + $module | Should -HaveCount 1 + $module.Version -ge '1.0.4.1' | Should -BeTrue + } + + It 'Should have a resource repository PSGallery with correct URI' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { + $resourceRepository = Get-PSResourceRepository -Name 'PSGallery' + + $resourceRepository | Should -HaveCount 1 + $resourceRepository.Uri | Should -Be 'https://www.powershellgallery.com/api/v2' + } + + It 'Should install SqlServer module version 21.1.18256' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') { + #Install-Module -Name 'SqlServer' -RequiredVersion '21.1.18256' -Force -ErrorAction 'Stop' + $module = Install-PSResource -Name 'SqlServer' -Version '21.1.18256' -Scope 'AllUsers' -TrustRepository -ErrorAction 'Stop' -Confirm:$false -PassThru + + $module | Should -HaveCount 1 + $module.Version -eq '21.1.18256' | Should -BeTrue + } + + It 'Should have SqlServer module version 21.1.18256 available' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') { + $module = Get-Module -Name 'SqlServer' -ListAvailable + + $module | Should -HaveCount 1 + $module.Version -eq '21.1.18256' | Should -BeTrue + } + + It 'Should install SqlServer module version 22.2.0' -Tag @('Integration_SQL2022') { + #Install-Module -Name 'SqlServer' -RequiredVersion '22.2.0' -Force -ErrorAction 'Stop' + $module = Install-PSResource -Name 'SqlServer' -Version '22.2.0' -Scope 'AllUsers' -TrustRepository -ErrorAction 'Stop' -Confirm:$false -PassThru + + $module | Should -HaveCount 1 + $module.Version -eq '22.2.0' | Should -BeTrue + } + + It 'Should have SqlServer module version 22.2.0 available' -Tag @('Integration_SQL2022') { + $module = Get-Module -Name 'SqlServer' -ListAvailable + + $module | Should -HaveCount 1 + $module.Version -eq '22.2.0' | Should -BeTrue + } + } + + Context 'Test PS Remoting to localhost' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { + It 'Should successfully run a command on localhost using PS Remoting' { + $result = Invoke-Command -ComputerName 'localhost' -ScriptBlock { 1 } -ErrorAction 'Stop' + + $result | Should -Be 1 + } + } +} diff --git a/tests/Integration/Commands/README.md b/tests/Integration/Commands/README.md index 7682dc9ac..1f37d55b7 100644 --- a/tests/Integration/Commands/README.md +++ b/tests/Integration/Commands/README.md @@ -5,19 +5,6 @@ Currently there are no possible to debug the commands on the service Appveyor since it has not been configured in the `appveyor.yml`. -## SqlServer module - -There is a difference what module version of [_SqlServer_](https://www.powershellgallery.com/packages/SqlServer) -is used for what SQL Server release. The integration tests for SqlSetup_ -installs the required module version. - -SQL Server release | SqlServer module version ---- | --- -SQL Server 2016 | 21.1.18256 -SQL Server 2017 | 21.1.18256 -SQL Server 2019 | 21.1.18256 -SQL Server 2022 | 22.2.0 - ## Depends On For it to be easier to write integration tests for a command that depends @@ -37,18 +24,40 @@ Install-SqlDscServer | 1 | - | - ## Integration Tests +### `Prerequisites`ยด + +Makes sure all dependencies are in place. This integration test always runs +first. + ### `Install-SqlDscServer` Installs all the [instances](#instances). -## Instances +## Dependencies + +### SqlServer module + +There is different module version of [_SqlServer_](https://www.powershellgallery.com/packages/SqlServer) +used depending on SQL Server release. The integration tests installs the +required module version according to the below table. + +SQL Server release | SqlServer module version +--- | --- +SQL Server 2016 | 21.1.18256 +SQL Server 2017 | 21.1.18256 +SQL Server 2019 | 21.1.18256 +SQL Server 2022 | 22.2.0 + +### Instances These instances is available for integration tests. + + Instance | Feature | State --- | --- | --- -DSCSQLTEST | SQLENGINE | - | Running -MSSQLSERVER | SQLENGINE | - | Stopped +DSCSQLTEST | SQLENGINE | Running +MSSQLSERVER | SQLENGINE | Stopped All running Database Engine instances also have a SQL Server Agent that is started. @@ -57,37 +66,39 @@ both Named Pipes and TCP/IP protocol enabled. > [!NOTE] > Some services are stopped to save memory on the build worker. See the -> column *State*. +> column _State_. -### Instance properties +#### Instance properties - **Collation:** Finnish\_Swedish\_CI\_AS - **InstallSharedDir:** C:\Program Files\Microsoft SQL Server - **InstallSharedWOWDir:** C:\Program Files (x86)\Microsoft SQL Server -## Users +### Users The following local users are created and can be used by integration tests. User | Password | Permission | Description --- | --- | --- | --- -.\SqlInstall | P@ssw0rd1 | Local Windows administrator. Administrator of Database Engine instance DSCSQLTEST\*. | Runs Setup for the default instance. -.\SqlAdmin | P@ssw0rd1 | Administrator of all SQL Server instances. | -.\svc-SqlPrimary | yig-C^Equ3 | Local user. | Runs the SQL Server Agent service. -.\svc-SqlAgentPri | yig-C^Equ3 | Local user. | Runs the SQL Server Agent service. -.\svc-SqlSecondary | yig-C^Equ3 | Local user. | Used by other tests, but created here. -.\svc-SqlAgentSec | yig-C^Equ3 | Local user. | Used by other tests. +.\SqlInstall | P@ssw0rd1 | Local Windows administrator and sysadmin | Runs Setup for all instances. +.\SqlAdmin | P@ssw0rd1 | Local Windows user and sysadmin | Administrator of all SQL Server instances. +.\svc-SqlPrimary | yig-C^Equ3 | Local Windows user. | Runs the SQL Server service. +.\svc-SqlAgentPri | yig-C^Equ3 | Local Windows user. | Runs the SQL Server Agent service. +.\svc-SqlSecondary | yig-C^Equ3 | Local Windows user. | Runs the SQL Server service in multi node scenarios. +.\svc-SqlAgentSec | yig-C^Equ3 | Local Windows user. | Runs the SQL Server Agent service in multi node scenarios. Login | Password | Permission | Description --- | --- | --- | --- -sa | P@ssw0rd1 | sysadmin | Administrator of the Database Engine instances DSCSQLTEST. | +sa | P@ssw0rd1 | sysadmin | Administrator of the Database Engine instances DSCSQLTEST. -## Image media (ISO) +### Image media (ISO) -The path to the image media is set in the environment variable `$env:IsoImagePath` -and the drive letter used to mount the image media is save in `$env:IsoDriveLetter`. +The environment variable `$env:IsoDriveLetter` contains the drive letter +(e.g. G, H, I) where the image media is mounted. The environment variable +`$env:IsoDrivePath` contains the drive root path +(e.g. G:\\, H:\\, I:\\) where the image media is mounted. This information can be used by integration tests that depends on the image media. diff --git a/tests/Unit/Public/Add-SqlDscNode.Tests.ps1 b/tests/Unit/Public/Add-SqlDscNode.Tests.ps1 index 01bd0f62d..8353c8d9e 100644 --- a/tests/Unit/Public/Add-SqlDscNode.Tests.ps1 +++ b/tests/Unit/Public/Add-SqlDscNode.Tests.ps1 @@ -50,7 +50,7 @@ AfterAll { Describe 'Add-SqlDscNode' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ - MockParameterSetName = '__AllParameterSets' + MockParameterSetName = '__AllParameterSets' # cSpell: disable-next MockExpectedParameters = '[-MediaPath] [-InstanceName] [[-UpdateSource] ] [[-PBEngSvcAccount] ] [[-PBEngSvcPassword] ] [[-PBEngSvcStartupType] ] [[-PBStartPortRange] ] [[-PBEndPortRange] ] [[-ProductKey] ] [[-AgtSvcAccount] ] [[-AgtSvcPassword] ] [[-ASSvcAccount] ] [[-ASSvcPassword] ] [[-SqlSvcAccount] ] [[-SqlSvcPassword] ] [[-ISSvcAccount] ] [[-ISSvcPassword] ] [[-RsInstallMode] ] [[-RSSvcAccount] ] [[-RSSvcPassword] ] [-FailoverClusterIPAddresses] [[-Timeout] ] -AcceptLicensingTerms [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-PBScaleOut] [-ConfirmIPDependencyChange] [-ProductCoveredBySA] [-Force] [-WhatIf] [-Confirm] []' } @@ -61,11 +61,11 @@ Describe 'Add-SqlDscNode' -Tag 'Public' { } | Select-Object -Property @( @{ - Name = 'ParameterSetName' + Name = 'ParameterSetName' Expression = { $_.Name } }, @{ - Name = 'ParameterListAsString' + Name = 'ParameterListAsString' Expression = { $_.ToString() } } ) @@ -92,15 +92,16 @@ Describe 'Add-SqlDscNode' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' FailoverClusterIPAddresses = @( 'IPv4;172.16.0.0;ClusterNetwork1;172.31.255.255', 'IPv6;2001:db8:23:1002:20f:1fff:feff:b3a3;ClusterNetwork2' # cspell: disable-line 'IPv6;DHCP;ClusterNetwork3' 'IPv4;DHCP;ClusterNetwork4' ) + ErrorAction = 'Stop' } } @@ -150,18 +151,18 @@ Describe 'Add-SqlDscNode' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $addSqlDscNodeParameters = @{ - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' FailoverClusterIPAddresses = @( 'IPv4;172.16.0.0;ClusterNetwork1;172.31.255.255', 'IPv6;2001:db8:23:1002:20f:1fff:feff:b3a3;ClusterNetwork2' # cspell: disable-line 'IPv6;DHCP;ClusterNetwork3' 'IPv4;DHCP;ClusterNetwork4' ) - Force = $true - PBStartPortRange = 16450 - PBEndPortRange = 16460 + Force = $true + PBStartPortRange = 16450 + PBEndPortRange = 16460 } } @@ -179,94 +180,94 @@ Describe 'Add-SqlDscNode' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'UpdateEnabled' + MockParameterName = 'UpdateEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line + MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line } @{ - MockParameterName = 'UpdateSource' + MockParameterName = 'UpdateSource' MockParameterValue = '\SqlMedia\Updates' - MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line + MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcAccount' + MockParameterName = 'PBEngSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcPassword' + MockParameterName = 'PBEngSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcStartupType' + MockParameterName = 'PBEngSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'PBScaleOut' + MockParameterName = 'PBScaleOut' MockParameterValue = $true - MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line + MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line } @{ - MockParameterName = 'ProductKey' + MockParameterName = 'ProductKey' MockParameterValue = '22222-00000-00000-00000-00000' - MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' + MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' } @{ - MockParameterName = 'AgtSvcAccount' + MockParameterName = 'AgtSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'AgtSvcPassword' + MockParameterName = 'AgtSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcAccount' + MockParameterName = 'AsSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ASSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcPassword' + MockParameterName = 'AsSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcAccount' + MockParameterName = 'SqlSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcPassword' + MockParameterName = 'SqlSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcAccount' + MockParameterName = 'ISSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcPassword' + MockParameterName = 'ISSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'RsInstallMode' + MockParameterName = 'RsInstallMode' MockParameterValue = 'FilesOnlyMode' - MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line + MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line } @{ - MockParameterName = 'ConfirmIPDependencyChange' + MockParameterName = 'ConfirmIPDependencyChange' MockParameterValue = $true - MockExpectedRegEx = '\/CONFIRMIPDEPENDENCYCHANGE=1' # cspell: disable-line + MockExpectedRegEx = '\/CONFIRMIPDEPENDENCYCHANGE=1' # cspell: disable-line } ) { BeforeAll { @@ -275,16 +276,17 @@ Describe 'Add-SqlDscNode' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' FailoverClusterIPAddresses = @( 'IPv4;172.16.0.0;ClusterNetwork1;172.31.255.255', 'IPv6;2001:db8:23:1002:20f:1fff:feff:b3a3;ClusterNetwork2' # cspell: disable-line 'IPv6;DHCP;ClusterNetwork3' 'IPv4;DHCP;ClusterNetwork4' ) - Force = $true + Force = $true + ErrorAction = 'Stop' } } diff --git a/tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1 b/tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1 index b4bcc6424..ad020898c 100644 --- a/tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1 +++ b/tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1 @@ -50,7 +50,7 @@ AfterAll { Describe 'Complete-SqlDscFailoverCluster' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ - MockParameterSetName = '__AllParameterSets' + MockParameterSetName = '__AllParameterSets' # cSpell: disable-next MockExpectedParameters = '[-MediaPath] [-InstanceName] [[-ProductKey] ] [[-ASBackupDir] ] [[-ASCollation] ] [[-ASConfigDir] ] [[-ASDataDir] ] [[-ASLogDir] ] [[-ASTempDir] ] [[-ASServerMode] ] [[-ASSysAdminAccounts] ] [-InstallSqlDataDir] [[-SqlBackupDir] ] [[-SecurityMode] ] [[-SAPwd] ] [[-SqlCollation] ] [-SqlSysAdminAccounts] [[-SqlTempDbDir] ] [[-SqlTempDbLogDir] ] [[-SqlTempDbFileCount] ] [[-SqlTempDbFileSize] ] [[-SqlTempDbFileGrowth] ] [[-SqlTempDbLogFileSize] ] [[-SqlTempDbLogFileGrowth] ] [[-SqlUserDbDir] ] [[-SqlUserDbLogDir] ] [[-RsInstallMode] ] [[-FailoverClusterGroup] ] [[-FailoverClusterDisks] ] [-FailoverClusterNetworkName] [-FailoverClusterIPAddresses] [[-Timeout] ] [-Enu] [-ASProviderMSOLAP] [-ConfirmIPDependencyChange] [-ProductCoveredBySA] [-Force] [-WhatIf] [-Confirm] []' } @@ -61,11 +61,11 @@ Describe 'Complete-SqlDscFailoverCluster' -Tag 'Public' { } | Select-Object -Property @( @{ - Name = 'ParameterSetName' + Name = 'ParameterSetName' Expression = { $_.Name } }, @{ - Name = 'ParameterListAsString' + Name = 'ParameterListAsString' Expression = { $_.ToString() } } ) @@ -92,10 +92,10 @@ Describe 'Complete-SqlDscFailoverCluster' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' - SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' - InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' + SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' + InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' FailoverClusterNetworkName = 'TESTCLU01A' # cspell: disable-line FailoverClusterIPAddresses = @( 'IPv4;172.16.0.0;ClusterNetwork1;172.31.255.255', @@ -103,6 +103,7 @@ Describe 'Complete-SqlDscFailoverCluster' -Tag 'Public' { 'IPv6;DHCP;ClusterNetwork3' 'IPv4;DHCP;ClusterNetwork4' ) + ErrorAction = 'Stop' } } @@ -153,155 +154,155 @@ Describe 'Complete-SqlDscFailoverCluster' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'ProductKey' + MockParameterName = 'ProductKey' MockParameterValue = '22222-00000-00000-00000-00000' - MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' + MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' } @{ - MockParameterName = 'ASBackupDir' + MockParameterName = 'ASBackupDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Backup' - MockExpectedRegEx = '\/ASBACKUPDIR="C:\\MSOLAP13\.INST2016\\Backup"' # cspell: disable-line + MockExpectedRegEx = '\/ASBACKUPDIR="C:\\MSOLAP13\.INST2016\\Backup"' # cspell: disable-line } @{ - MockParameterName = 'ASConfigDir' + MockParameterName = 'ASConfigDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Config' - MockExpectedRegEx = '\/ASCONFIGDIR="C:\\MSOLAP13\.INST2016\\Config"' # cspell: disable-line + MockExpectedRegEx = '\/ASCONFIGDIR="C:\\MSOLAP13\.INST2016\\Config"' # cspell: disable-line } @{ - MockParameterName = 'ASDataDir' + MockParameterName = 'ASDataDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Data' - MockExpectedRegEx = '\/ASDATADIR="C:\\MSOLAP13\.INST2016\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/ASDATADIR="C:\\MSOLAP13\.INST2016\\Data"' # cspell: disable-line } @{ - MockParameterName = 'ASLogDir' + MockParameterName = 'ASLogDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Log' - MockExpectedRegEx = '\/ASLOGDIR="C:\\MSOLAP13\.INST2016\\Log"' # cspell: disable-line + MockExpectedRegEx = '\/ASLOGDIR="C:\\MSOLAP13\.INST2016\\Log"' # cspell: disable-line } @{ - MockParameterName = 'ASTempDir' + MockParameterName = 'ASTempDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Temp' - MockExpectedRegEx = '\/ASTEMPDIR="C:\\MSOLAP13\.INST2016\\Temp"' # cspell: disable-line + MockExpectedRegEx = '\/ASTEMPDIR="C:\\MSOLAP13\.INST2016\\Temp"' # cspell: disable-line } @{ - MockParameterName = 'ASCollation' + MockParameterName = 'ASCollation' MockParameterValue = 'latin1_general_100' - MockExpectedRegEx = '\/ASCOLLATION="latin1_general_100"' # cspell: disable-line + MockExpectedRegEx = '\/ASCOLLATION="latin1_general_100"' # cspell: disable-line } @{ - MockParameterName = 'ASServerMode' + MockParameterName = 'ASServerMode' MockParameterValue = 'Multidimensional' - MockExpectedRegEx = '\/ASSERVERMODE=MULTIDIMENSIONAL' # cspell: disable-line + MockExpectedRegEx = '\/ASSERVERMODE=MULTIDIMENSIONAL' # cspell: disable-line } @{ - MockParameterName = 'ASSysAdminAccounts' + MockParameterName = 'ASSysAdminAccounts' MockParameterValue = 'COMPANY\SQL Administrators', 'LocalUser' - MockExpectedRegEx = '\/ASSYSADMINACCOUNTS="COMPANY\\SQL Administrators" "LocalUser"' # cspell: disable-line + MockExpectedRegEx = '\/ASSYSADMINACCOUNTS="COMPANY\\SQL Administrators" "LocalUser"' # cspell: disable-line } @{ - MockParameterName = 'ASProviderMSOLAP' + MockParameterName = 'ASProviderMSOLAP' MockParameterValue = $true - MockExpectedRegEx = '\/ASPROVIDERMSOLAP=1' # cspell: disable-line + MockExpectedRegEx = '\/ASPROVIDERMSOLAP=1' # cspell: disable-line } @{ - MockParameterName = 'InstallSqlDataDir' + MockParameterName = 'InstallSqlDataDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/INSTALLSQLDATADIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSQLDATADIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlBackupDir' + MockParameterName = 'SqlBackupDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Backup' - MockExpectedRegEx = '\/SQLBACKUPDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Backup"' # cspell: disable-line + MockExpectedRegEx = '\/SQLBACKUPDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Backup"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbDir' + MockParameterName = 'SqlTempDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogDir' + MockParameterName = 'SqlTempDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlUserDbDir' + MockParameterName = 'SqlUserDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLUSERDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLUSERDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlUserDbLogDir' + MockParameterName = 'SqlUserDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLUSERDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLUSERDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SecurityMode' + MockParameterName = 'SecurityMode' MockParameterValue = 'SQL' - MockExpectedRegEx = '\/SECURITYMODE="SQL"' # cspell: disable-line + MockExpectedRegEx = '\/SECURITYMODE="SQL"' # cspell: disable-line } @{ - MockParameterName = 'SAPwd' + MockParameterName = 'SAPwd' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlCollation' + MockParameterName = 'SqlCollation' MockParameterValue = 'SQL_Latin1_General_CP1_CI_AS' - MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line + MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileCount' + MockParameterName = 'SqlTempDbFileCount' MockParameterValue = 8 - MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileSize' + MockParameterName = 'SqlTempDbFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileGrowth' + MockParameterName = 'SqlTempDbFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileSize' + MockParameterName = 'SqlTempDbLogFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileGrowth' + MockParameterName = 'SqlTempDbLogFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'RsInstallMode' + MockParameterName = 'RsInstallMode' MockParameterValue = 'FilesOnlyMode' - MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line + MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line } @{ - MockParameterName = 'FailoverClusterGroup' + MockParameterName = 'FailoverClusterGroup' MockParameterValue = 'TESTCLU01A' # cspell: disable-line - MockExpectedRegEx = '\/FAILOVERCLUSTERGROUP="TESTCLU01A"' # cspell: disable-line + MockExpectedRegEx = '\/FAILOVERCLUSTERGROUP="TESTCLU01A"' # cspell: disable-line } @{ - MockParameterName = 'FailoverClusterGroup' + MockParameterName = 'FailoverClusterGroup' MockParameterValue = 'TESTCLU01A' # cspell: disable-line - MockExpectedRegEx = '\/FAILOVERCLUSTERGROUP="TESTCLU01A"' # cspell: disable-line + MockExpectedRegEx = '\/FAILOVERCLUSTERGROUP="TESTCLU01A"' # cspell: disable-line } @{ - MockParameterName = 'FailoverClusterDisks' + MockParameterName = 'FailoverClusterDisks' # This is the failover cluster resource name. MockParameterValue = @( 'SysData' ) - MockExpectedRegEx = '\/FAILOVERCLUSTERDISKS="SysData"' # cspell: disable-line + MockExpectedRegEx = '\/FAILOVERCLUSTERDISKS="SysData"' # cspell: disable-line } @{ - MockParameterName = 'FailoverClusterDisks' + MockParameterName = 'FailoverClusterDisks' # This is the failover cluster resource names. MockParameterValue = @( 'Backup' @@ -311,12 +312,12 @@ Describe 'Complete-SqlDscFailoverCluster' -Tag 'Public' { 'UserData' 'UserLogs' ) - MockExpectedRegEx = '\/FAILOVERCLUSTERDISKS="Backup;SysData;TempDbData;TempDbLogs;UserData;UserLogs"' # cspell: disable-line + MockExpectedRegEx = '\/FAILOVERCLUSTERDISKS="Backup;SysData;TempDbData;TempDbLogs;UserData;UserLogs"' # cspell: disable-line } @{ - MockParameterName = 'ConfirmIPDependencyChange' + MockParameterName = 'ConfirmIPDependencyChange' MockParameterValue = $true - MockExpectedRegEx = '\/CONFIRMIPDEPENDENCYCHANGE=1' # cspell: disable-line + MockExpectedRegEx = '\/CONFIRMIPDEPENDENCYCHANGE=1' # cspell: disable-line } ) { BeforeAll { @@ -325,10 +326,10 @@ Describe 'Complete-SqlDscFailoverCluster' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' - SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' - InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' + SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' + InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' FailoverClusterNetworkName = 'TESTCLU01A' # cspell: disable-line FailoverClusterIPAddresses = @( 'IPv4;172.16.0.0;ClusterNetwork1;172.31.255.255', @@ -336,7 +337,8 @@ Describe 'Complete-SqlDscFailoverCluster' -Tag 'Public' { 'IPv6;DHCP;ClusterNetwork3' 'IPv4;DHCP;ClusterNetwork4' ) - Force = $true + Force = $true + ErrorAction = 'Stop' } } diff --git a/tests/Unit/Public/Complete-SqlDscImage.Tests.ps1 b/tests/Unit/Public/Complete-SqlDscImage.Tests.ps1 index 6d27867e1..8e7fa4b4b 100644 --- a/tests/Unit/Public/Complete-SqlDscImage.Tests.ps1 +++ b/tests/Unit/Public/Complete-SqlDscImage.Tests.ps1 @@ -50,7 +50,7 @@ AfterAll { Describe 'Complete-SqlDscImage' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ - MockParameterSetName = '__AllParameterSets' + MockParameterSetName = '__AllParameterSets' # cSpell: disable-next MockExpectedParameters = '[-MediaPath] [[-InstanceName] ] [[-InstanceId] ] [[-PBEngSvcAccount] ] [[-PBEngSvcPassword] ] [[-PBEngSvcStartupType] ] [[-PBStartPortRange] ] [[-PBEndPortRange] ] [[-ProductKey] ] [[-AgtSvcAccount] ] [[-AgtSvcPassword] ] [[-AgtSvcStartupType] ] [[-BrowserSvcStartupType] ] [[-InstallSqlDataDir] ] [[-SqlBackupDir] ] [[-SecurityMode] ] [[-SAPwd] ] [[-SqlCollation] ] [[-SqlSvcAccount] ] [[-SqlSvcPassword] ] [[-SqlSvcStartupType] ] [[-SqlSysAdminAccounts] ] [[-SqlTempDbDir] ] [[-SqlTempDbLogDir] ] [[-SqlTempDbFileCount] ] [[-SqlTempDbFileSize] ] [[-SqlTempDbFileGrowth] ] [[-SqlTempDbLogFileSize] ] [[-SqlTempDbLogFileGrowth] ] [[-SqlUserDbDir] ] [[-SqlUserDbLogDir] ] [[-FileStreamLevel] ] [[-FileStreamShareName] ] [[-RsInstallMode] ] [[-RSSvcAccount] ] [[-RSSvcPassword] ] [[-RSSvcStartupType] ] [[-Timeout] ] -AcceptLicensingTerms [-Enu] [-PBScaleOut] [-EnableRanU] [-NpEnabled] [-TcpEnabled] [-ProductCoveredBySA] [-Force] [-WhatIf] [-Confirm] []' } @@ -61,11 +61,11 @@ Describe 'Complete-SqlDscImage' -Tag 'Public' { } | Select-Object -Property @( @{ - Name = 'ParameterSetName' + Name = 'ParameterSetName' Expression = { $_.Name } }, @{ - Name = 'ParameterListAsString' + Name = 'ParameterListAsString' Expression = { $_.ToString() } } ) @@ -93,7 +93,8 @@ Describe 'Complete-SqlDscImage' -Tag 'Public' { $mockDefaultParameters = @{ AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' + ErrorAction = 'Stop' } } @@ -140,10 +141,10 @@ Describe 'Complete-SqlDscImage' -Tag 'Public' { $completeSqlDscImageParameters = @{ AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - Force = $true - PBStartPortRange = 16450 - PBEndPortRange = 16460 + MediaPath = '\SqlMedia' + Force = $true + PBStartPortRange = 16450 + PBEndPortRange = 16460 } } @@ -161,194 +162,194 @@ Describe 'Complete-SqlDscImage' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'InstanceName' + MockParameterName = 'InstanceName' MockParameterValue = 'INSTANCE' - MockExpectedRegEx = '\/INSTANCENAME="INSTANCE"*' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCENAME="INSTANCE"*' # cspell: disable-line } @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'InstanceId' + MockParameterName = 'InstanceId' MockParameterValue = 'Instance' - MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcAccount' + MockParameterName = 'PBEngSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcPassword' + MockParameterName = 'PBEngSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcStartupType' + MockParameterName = 'PBEngSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'PBScaleOut' + MockParameterName = 'PBScaleOut' MockParameterValue = $true - MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line + MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line } @{ - MockParameterName = 'ProductKey' + MockParameterName = 'ProductKey' MockParameterValue = '22222-00000-00000-00000-00000' - MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' + MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' } @{ - MockParameterName = 'AgtSvcAccount' + MockParameterName = 'AgtSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'AgtSvcPassword' + MockParameterName = 'AgtSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'AgtSvcStartupType' + MockParameterName = 'AgtSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/AGTSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'BrowserSvcStartupType' + MockParameterName = 'BrowserSvcStartupType' MockParameterValue = 'Manual' - MockExpectedRegEx = '\/BROWSERSVCSTARTUPTYPE="Manual"' # cspell: disable-line + MockExpectedRegEx = '\/BROWSERSVCSTARTUPTYPE="Manual"' # cspell: disable-line } @{ - MockParameterName = 'EnableRanU' + MockParameterName = 'EnableRanU' MockParameterValue = $true - MockExpectedRegEx = '\/ENABLERANU' # cspell: disable-line + MockExpectedRegEx = '\/ENABLERANU' # cspell: disable-line } @{ - MockParameterName = 'InstallSqlDataDir' + MockParameterName = 'InstallSqlDataDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/INSTALLSQLDATADIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSQLDATADIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlBackupDir' + MockParameterName = 'SqlBackupDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Backup' - MockExpectedRegEx = '\/SQLBACKUPDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Backup"' # cspell: disable-line + MockExpectedRegEx = '\/SQLBACKUPDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Backup"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbDir' + MockParameterName = 'SqlTempDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogDir' + MockParameterName = 'SqlTempDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlUserDbDir' + MockParameterName = 'SqlUserDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLUSERDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLUSERDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlUserDbLogDir' + MockParameterName = 'SqlUserDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLUSERDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLUSERDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SecurityMode' + MockParameterName = 'SecurityMode' MockParameterValue = 'SQL' - MockExpectedRegEx = '\/SECURITYMODE="SQL"' # cspell: disable-line + MockExpectedRegEx = '\/SECURITYMODE="SQL"' # cspell: disable-line } @{ - MockParameterName = 'SAPwd' + MockParameterName = 'SAPwd' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlCollation' + MockParameterName = 'SqlCollation' MockParameterValue = 'SQL_Latin1_General_CP1_CI_AS' - MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line + MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcAccount' + MockParameterName = 'SqlSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcPassword' + MockParameterName = 'SqlSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcStartupType' + MockParameterName = 'SqlSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/SQLSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileCount' + MockParameterName = 'SqlTempDbFileCount' MockParameterValue = 8 - MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileSize' + MockParameterName = 'SqlTempDbFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileGrowth' + MockParameterName = 'SqlTempDbFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileSize' + MockParameterName = 'SqlTempDbLogFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileGrowth' + MockParameterName = 'SqlTempDbLogFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'FileStreamLevel' + MockParameterName = 'FileStreamLevel' MockParameterValue = 2 - MockExpectedRegEx = '\/FILESTREAMLEVEL=2' # cspell: disable-line + MockExpectedRegEx = '\/FILESTREAMLEVEL=2' # cspell: disable-line } @{ - MockParameterName = 'FileStreamShareName' + MockParameterName = 'FileStreamShareName' MockParameterValue = 'ShareName' - MockExpectedRegEx = '\/FILESTREAMSHARENAME="ShareName"' # cspell: disable-line + MockExpectedRegEx = '\/FILESTREAMSHARENAME="ShareName"' # cspell: disable-line } @{ - MockParameterName = 'NpEnabled' + MockParameterName = 'NpEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/NPENABLED=1' # cspell: disable-line + MockExpectedRegEx = '\/NPENABLED=1' # cspell: disable-line } @{ - MockParameterName = 'TcpEnabled' + MockParameterName = 'TcpEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/TCPENABLED=1' # cspell: disable-line + MockExpectedRegEx = '\/TCPENABLED=1' # cspell: disable-line } @{ - MockParameterName = 'RsInstallMode' + MockParameterName = 'RsInstallMode' MockParameterValue = 'FilesOnlyMode' - MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line + MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcAccount' + MockParameterName = 'RSSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/RSSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcPassword' + MockParameterName = 'RSSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcStartupType' + MockParameterName = 'RSSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/RSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } ) { BeforeAll { @@ -358,8 +359,9 @@ Describe 'Complete-SqlDscImage' -Tag 'Public' { $mockDefaultParameters = @{ AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - Force = $true + MediaPath = '\SqlMedia' + Force = $true + ErrorAction = 'Stop' } } diff --git a/tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1 b/tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1 index b96753aca..92395bb03 100644 --- a/tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1 +++ b/tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1 @@ -50,7 +50,7 @@ AfterAll { Describe 'Initialize-SqlDscRebuildDatabase' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ - MockParameterSetName = '__AllParameterSets' + MockParameterSetName = '__AllParameterSets' # cSpell: disable-next MockExpectedParameters = '[-MediaPath] [-InstanceName] [[-SAPwd] ] [[-SqlCollation] ] [-SqlSysAdminAccounts] [[-SqlTempDbDir] ] [[-SqlTempDbLogDir] ] [[-SqlTempDbFileCount] ] [[-SqlTempDbFileSize] ] [[-SqlTempDbFileGrowth] ] [[-SqlTempDbLogFileSize] ] [[-SqlTempDbLogFileGrowth] ] [[-Timeout] ] [-Force] [-WhatIf] [-Confirm] []' } @@ -61,11 +61,11 @@ Describe 'Initialize-SqlDscRebuildDatabase' -Tag 'Public' { } | Select-Object -Property @( @{ - Name = 'ParameterSetName' + Name = 'ParameterSetName' Expression = { $_.Name } }, @{ - Name = 'ParameterListAsString' + Name = 'ParameterListAsString' Expression = { $_.ToString() } } ) @@ -92,9 +92,10 @@ Describe 'Initialize-SqlDscRebuildDatabase' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' + ErrorAction = 'Stop' } } @@ -139,49 +140,49 @@ Describe 'Initialize-SqlDscRebuildDatabase' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'SqlTempDbDir' + MockParameterName = 'SqlTempDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogDir' + MockParameterName = 'SqlTempDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SAPwd' + MockParameterName = 'SAPwd' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlCollation' + MockParameterName = 'SqlCollation' MockParameterValue = 'SQL_Latin1_General_CP1_CI_AS' - MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line + MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileCount' + MockParameterName = 'SqlTempDbFileCount' MockParameterValue = 8 - MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileSize' + MockParameterName = 'SqlTempDbFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileGrowth' + MockParameterName = 'SqlTempDbFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileSize' + MockParameterName = 'SqlTempDbLogFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileGrowth' + MockParameterName = 'SqlTempDbLogFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line } ) { BeforeAll { @@ -190,10 +191,11 @@ Describe 'Initialize-SqlDscRebuildDatabase' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' SqlSysAdminAccounts = 'DOMAIN\User' - Force = $true + Force = $true + ErrorAction = 'Stop' } } diff --git a/tests/Unit/Public/Install-SqlDscServer.Tests.ps1 b/tests/Unit/Public/Install-SqlDscServer.Tests.ps1 index 61fa0fc8c..c95fd4244 100644 --- a/tests/Unit/Public/Install-SqlDscServer.Tests.ps1 +++ b/tests/Unit/Public/Install-SqlDscServer.Tests.ps1 @@ -50,47 +50,47 @@ AfterAll { Describe 'Install-SqlDscServer' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ - MockParameterSetName = 'Install' + MockParameterSetName = 'Install' # cSpell: disable-next MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath -InstanceName -Features [-SuppressPrivacyStatementNotice] [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource ] [-InstallSharedDir ] [-InstallSharedWowDir ] [-InstanceDir ] [-InstanceId ] [-PBEngSvcAccount ] [-PBEngSvcPassword ] [-PBEngSvcStartupType ] [-PBDMSSvcAccount ] [-PBDMSSvcPassword ] [-PBDMSSvcStartupType ] [-PBStartPortRange ] [-PBEndPortRange ] [-PBScaleOut] [-ProductKey ] [-AgtSvcAccount ] [-AgtSvcPassword ] [-AgtSvcStartupType ] [-ASBackupDir ] [-ASCollation ] [-ASConfigDir ] [-ASDataDir ] [-ASLogDir ] [-ASTempDir ] [-ASServerMode ] [-ASSvcAccount ] [-ASSvcPassword ] [-ASSvcStartupType ] [-ASSysAdminAccounts ] [-ASProviderMSOLAP] [-BrowserSvcStartupType ] [-EnableRanU] [-InstallSqlDataDir ] [-SqlBackupDir ] [-SecurityMode ] [-SAPwd ] [-SqlCollation ] [-SqlSvcAccount ] [-SqlSvcPassword ] [-SqlSvcStartupType ] [-SqlSysAdminAccounts ] [-SqlTempDbDir ] [-SqlTempDbLogDir ] [-SqlTempDbFileCount ] [-SqlTempDbFileSize ] [-SqlTempDbFileGrowth ] [-SqlTempDbLogFileSize ] [-SqlTempDbLogFileGrowth ] [-SqlUserDbDir ] [-SqlSvcInstantFileInit] [-SqlUserDbLogDir ] [-SqlMaxDop ] [-UseSqlRecommendedMemoryLimits] [-SqlMinMemory ] [-SqlMaxMemory ] [-FileStreamLevel ] [-FileStreamShareName ] [-ISSvcAccount ] [-ISSvcPassword ] [-ISSvcStartupType ] [-NpEnabled] [-TcpEnabled] [-RsInstallMode ] [-RSSvcAccount ] [-RSSvcPassword ] [-RSSvcStartupType ] [-MPYCacheDirectory ] [-MRCacheDirectory ] [-SqlInstJava] [-SqlJavaDir ] [-AzureSubscriptionId ] [-AzureResourceGroup ] [-AzureRegion ] [-AzureTenantId ] [-AzureServicePrincipal ] [-AzureServicePrincipalSecret ] [-AzureArcProxy ] [-SkipRules ] [-ProductCoveredBySA] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @{ - MockParameterSetName = 'InstallRole' + MockParameterSetName = 'InstallRole' # cSpell: disable-next MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath -Role [-SuppressPrivacyStatementNotice] [-IAcknowledgeEntCalLimits] [-InstanceName ] [-Enu] [-UpdateEnabled] [-UpdateSource ] [-Features ] [-InstallSharedDir ] [-InstallSharedWowDir ] [-InstanceDir ] [-InstanceId ] [-PBEngSvcAccount ] [-PBEngSvcPassword ] [-PBEngSvcStartupType ] [-PBDMSSvcAccount ] [-PBDMSSvcPassword ] [-PBDMSSvcStartupType ] [-PBStartPortRange ] [-PBEndPortRange ] [-PBScaleOut] [-ProductKey ] [-AgtSvcAccount ] [-AgtSvcPassword ] [-AgtSvcStartupType ] [-ASBackupDir ] [-ASCollation ] [-ASConfigDir ] [-ASDataDir ] [-ASLogDir ] [-ASTempDir ] [-ASServerMode ] [-ASSvcAccount ] [-ASSvcPassword ] [-ASSvcStartupType ] [-ASSysAdminAccounts ] [-ASProviderMSOLAP] [-FarmAccount ] [-FarmPassword ] [-Passphrase ] [-FarmAdminiPort ] [-BrowserSvcStartupType ] [-EnableRanU] [-InstallSqlDataDir ] [-SqlBackupDir ] [-SecurityMode ] [-SAPwd ] [-SqlCollation ] [-AddCurrentUserAsSqlAdmin] [-SqlSvcAccount ] [-SqlSvcPassword ] [-SqlSvcStartupType ] [-SqlSysAdminAccounts ] [-SqlTempDbDir ] [-SqlTempDbLogDir ] [-SqlTempDbFileCount ] [-SqlTempDbFileSize ] [-SqlTempDbFileGrowth ] [-SqlTempDbLogFileSize ] [-SqlTempDbLogFileGrowth ] [-SqlUserDbDir ] [-SqlSvcInstantFileInit] [-SqlUserDbLogDir ] [-SqlMaxDop ] [-UseSqlRecommendedMemoryLimits] [-SqlMinMemory ] [-SqlMaxMemory ] [-FileStreamLevel ] [-FileStreamShareName ] [-ISSvcAccount ] [-ISSvcPassword ] [-ISSvcStartupType ] [-NpEnabled] [-TcpEnabled] [-RsInstallMode ] [-RSSvcAccount ] [-RSSvcPassword ] [-RSSvcStartupType ] [-MPYCacheDirectory ] [-MRCacheDirectory ] [-SqlInstJava] [-SqlJavaDir ] [-AzureSubscriptionId ] [-AzureResourceGroup ] [-AzureRegion ] [-AzureTenantId ] [-AzureServicePrincipal ] [-AzureServicePrincipalSecret ] [-AzureArcProxy ] [-SkipRules ] [-ProductCoveredBySA] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @{ - MockParameterSetName = 'InstallAzureArcAgent' + MockParameterSetName = 'InstallAzureArcAgent' # cSpell: disable-next MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath -AzureSubscriptionId -AzureResourceGroup -AzureRegion -AzureTenantId -AzureServicePrincipal -AzureServicePrincipalSecret [-AzureArcProxy ] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @{ - MockParameterSetName = 'UsingConfigurationFile' + MockParameterSetName = 'UsingConfigurationFile' # cSpell: disable-next MockExpectedParameters = '-ConfigurationFile -MediaPath [-AgtSvcPassword ] [-ASSvcPassword ] [-SqlSvcPassword ] [-ISSvcPassword ] [-RSSvcPassword ] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @{ - MockParameterSetName = 'PrepareImage' + MockParameterSetName = 'PrepareImage' # cSpell: disable-next MockExpectedParameters = '-PrepareImage -AcceptLicensingTerms -MediaPath -Features -InstanceId [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource ] [-InstallSharedDir ] [-InstanceDir ] [-PBEngSvcAccount ] [-PBEngSvcPassword ] [-PBEngSvcStartupType ] [-PBStartPortRange ] [-PBEndPortRange ] [-PBScaleOut] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @{ - MockParameterSetName = 'Upgrade' + MockParameterSetName = 'Upgrade' # cSpell: disable-next MockExpectedParameters = '-Upgrade -AcceptLicensingTerms -MediaPath -InstanceName [-Enu] [-UpdateEnabled] [-UpdateSource ] [-InstanceDir ] [-InstanceId ] [-ProductKey ] [-BrowserSvcStartupType ] [-FTUpgradeOption ] [-ISSvcAccount ] [-ISSvcPassword ] [-ISSvcStartupType ] [-AllowUpgradeForSSRSSharePointMode] [-FailoverClusterRollOwnership ] [-ProductCoveredBySA] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @{ - MockParameterSetName = 'EditionUpgrade' + MockParameterSetName = 'EditionUpgrade' # cSpell: disable-next MockExpectedParameters = '-EditionUpgrade -AcceptLicensingTerms -MediaPath -InstanceName -ProductKey [-SkipRules ] [-ProductCoveredBySA] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @{ - MockParameterSetName = 'InstallFailoverCluster' + MockParameterSetName = 'InstallFailoverCluster' # cSpell: disable-next MockExpectedParameters = '-InstallFailoverCluster -AcceptLicensingTerms -MediaPath -InstanceName -Features -InstallSqlDataDir -SqlSysAdminAccounts -FailoverClusterNetworkName -FailoverClusterIPAddresses [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource ] [-InstallSharedDir ] [-InstallSharedWowDir ] [-InstanceDir ] [-InstanceId ] [-PBEngSvcAccount ] [-PBEngSvcPassword ] [-PBEngSvcStartupType ] [-PBStartPortRange ] [-PBEndPortRange ] [-PBScaleOut] [-ProductKey ] [-AgtSvcAccount ] [-AgtSvcPassword ] [-ASBackupDir ] [-ASCollation ] [-ASConfigDir ] [-ASDataDir ] [-ASLogDir ] [-ASTempDir ] [-ASServerMode ] [-ASSvcAccount ] [-ASSvcPassword ] [-ASSvcStartupType ] [-ASSysAdminAccounts ] [-ASProviderMSOLAP] [-SqlBackupDir ] [-SecurityMode ] [-SAPwd ] [-SqlCollation ] [-SqlSvcAccount ] [-SqlSvcPassword ] [-SqlSvcStartupType ] [-SqlTempDbDir ] [-SqlTempDbLogDir ] [-SqlTempDbFileCount ] [-SqlTempDbFileSize ] [-SqlTempDbFileGrowth ] [-SqlTempDbLogFileSize ] [-SqlTempDbLogFileGrowth ] [-SqlUserDbDir ] [-SqlUserDbLogDir ] [-FileStreamLevel ] [-FileStreamShareName ] [-ISSvcAccount ] [-ISSvcPassword ] [-ISSvcStartupType ] [-RsInstallMode ] [-RSSvcAccount ] [-RSSvcPassword ] [-RSSvcStartupType ] [-FailoverClusterGroup ] [-FailoverClusterDisks ] [-SkipRules ] [-ProductCoveredBySA] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @{ - MockParameterSetName = 'PrepareFailoverCluster' + MockParameterSetName = 'PrepareFailoverCluster' # cSpell: disable-next MockExpectedParameters = '-PrepareFailoverCluster -AcceptLicensingTerms -MediaPath -InstanceName -Features [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource ] [-InstallSharedDir ] [-InstallSharedWowDir ] [-InstanceDir ] [-InstanceId ] [-PBEngSvcAccount ] [-PBEngSvcPassword ] [-PBEngSvcStartupType ] [-PBStartPortRange ] [-PBEndPortRange ] [-PBScaleOut] [-ProductKey ] [-AgtSvcAccount ] [-AgtSvcPassword ] [-ASSvcAccount ] [-ASSvcPassword ] [-SqlSvcAccount ] [-SqlSvcPassword ] [-FileStreamLevel ] [-FileStreamShareName ] [-ISSvcAccount ] [-ISSvcPassword ] [-ISSvcStartupType ] [-RsInstallMode ] [-RSSvcAccount ] [-RSSvcPassword ] [-RSSvcStartupType ] [-ProductCoveredBySA] [-Timeout ] [-Force] [-WhatIf] [-Confirm] []' } @@ -101,11 +101,11 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } | Select-Object -Property @( @{ - Name = 'ParameterSetName' + Name = 'ParameterSetName' Expression = { $_.Name } }, @{ - Name = 'ParameterListAsString' + Name = 'ParameterListAsString' Expression = { $_.ToString() } } ) @@ -132,13 +132,14 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case. - Features = 'SqlEngine', 'AZUREEXTENSION' - SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' + Features = 'SqlEngine', 'AZUREEXTENSION' # cspell: disable-line + SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' + ErrorAction = 'Stop' } } @@ -150,7 +151,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $ArgumentList | Should -MatchExactly '\/ACTION=Install' $ArgumentList | Should -MatchExactly '\/IACCEPTSQLSERVERLICENSETERMS' # cspell: disable-line $ArgumentList | Should -MatchExactly '\/SQLSYSADMINACCOUNTS="DOMAIN\\User" "COMPANY\\SQL Administrators"' # cspell: disable-line - $ArgumentList | Should -MatchExactly '\/FEATURES=SQLENGINE,AZUREEXTENSION' + $ArgumentList | Should -MatchExactly '\/FEATURES=SQLENGINE,AZUREEXTENSION' # cspell: disable-line $ArgumentList | Should -MatchExactly '\/INSTANCENAME="INSTANCE"' # cspell: disable-line # Return $true if none of the above throw. @@ -167,7 +168,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $ArgumentList | Should -MatchExactly '\/ACTION=Install' $ArgumentList | Should -MatchExactly '\/IACCEPTSQLSERVERLICENSETERMS' # cspell: disable-line $ArgumentList | Should -MatchExactly '\/SQLSYSADMINACCOUNTS="DOMAIN\\User" "COMPANY\\SQL Administrators"' # cspell: disable-line - $ArgumentList | Should -MatchExactly '\/FEATURES=SQLENGINE,AZUREEXTENSION' + $ArgumentList | Should -MatchExactly '\/FEATURES=SQLENGINE,AZUREEXTENSION' # cspell: disable-line $ArgumentList | Should -MatchExactly '\/INSTANCENAME="INSTANCE"' # cspell: disable-line # Return $true if none of the above throw. @@ -192,16 +193,17 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $installSqlDscServerParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - SqlSysAdminAccounts = 'DOMAIN\User' - Force = $true - PBStartPortRange = 16450 - PBEndPortRange = 16460 + Features = 'SqlEngine' + SqlSysAdminAccounts = 'DOMAIN\User' + Force = $true + PBStartPortRange = 16450 + PBEndPortRange = 16460 + ErrorAction = 'Stop' } } @@ -219,400 +221,400 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'SuppressPrivacyStatementNotice' + MockParameterName = 'SuppressPrivacyStatementNotice' MockParameterValue = $true - MockExpectedRegEx = '\/SUPPRESSPRIVACYSTATEMENTNOTICE\s*' # cspell: disable-line + MockExpectedRegEx = '\/SUPPRESSPRIVACYSTATEMENTNOTICE\s*' # cspell: disable-line } @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'UpdateEnabled' + MockParameterName = 'UpdateEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line + MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line } @{ - MockParameterName = 'UpdateSource' + MockParameterName = 'UpdateSource' MockParameterValue = '\SqlMedia\Updates' - MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line + MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line } @{ - MockParameterName = 'InstallSharedDir' + MockParameterName = 'InstallSharedDir' # This value intentionally ends with a backslash to test so that it is removed. MockParameterValue = 'C:\Program Files\Microsoft SQL Server\' - MockExpectedRegEx = '\/INSTALLSHAREDDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSHAREDDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstallSharedWOWDir' + MockParameterName = 'InstallSharedWOWDir' MockParameterValue = 'C:\Program Files (x86)\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTALLSHAREDWOWDIR="C:\\Program Files \(x86\)\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSHAREDWOWDIR="C:\\Program Files \(x86\)\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstanceDir' + MockParameterName = 'InstanceDir' <# This value intentionally has 'D:\' to validate that the backslash is not removed and that the argument is passed without double-quotes. #> MockParameterValue = 'D:\' - MockExpectedRegEx = '\/INSTANCEDIR=D:\\' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEDIR=D:\\' # cspell: disable-line } @{ - MockParameterName = 'InstanceId' + MockParameterName = 'InstanceId' MockParameterValue = 'Instance' - MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcAccount' + MockParameterName = 'PBEngSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcPassword' + MockParameterName = 'PBEngSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcStartupType' + MockParameterName = 'PBEngSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'PBDMSSvcAccount' # cspell: disable-line + MockParameterName = 'PBDMSSvcAccount' # cspell: disable-line MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/PBDMSSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/PBDMSSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'PBDMSSvcPassword' # cspell: disable-line + MockParameterName = 'PBDMSSvcPassword' # cspell: disable-line MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBDMSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PBDMSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'PBDMSSvcStartupType' # cspell: disable-line + MockParameterName = 'PBDMSSvcStartupType' # cspell: disable-line MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/PBDMSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/PBDMSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'PBScaleOut' + MockParameterName = 'PBScaleOut' MockParameterValue = $true - MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line + MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line } @{ - MockParameterName = 'ProductKey' + MockParameterName = 'ProductKey' MockParameterValue = '22222-00000-00000-00000-00000' - MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' + MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' } @{ - MockParameterName = 'AgtSvcAccount' + MockParameterName = 'AgtSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'AgtSvcPassword' + MockParameterName = 'AgtSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'AgtSvcStartupType' + MockParameterName = 'AgtSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/AGTSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'ASBackupDir' + MockParameterName = 'ASBackupDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Backup' - MockExpectedRegEx = '\/ASBACKUPDIR="C:\\MSOLAP13\.INST2016\\Backup"' # cspell: disable-line + MockExpectedRegEx = '\/ASBACKUPDIR="C:\\MSOLAP13\.INST2016\\Backup"' # cspell: disable-line } @{ - MockParameterName = 'ASConfigDir' + MockParameterName = 'ASConfigDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Config' - MockExpectedRegEx = '\/ASCONFIGDIR="C:\\MSOLAP13\.INST2016\\Config"' # cspell: disable-line + MockExpectedRegEx = '\/ASCONFIGDIR="C:\\MSOLAP13\.INST2016\\Config"' # cspell: disable-line } @{ - MockParameterName = 'ASDataDir' + MockParameterName = 'ASDataDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Data' - MockExpectedRegEx = '\/ASDATADIR="C:\\MSOLAP13\.INST2016\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/ASDATADIR="C:\\MSOLAP13\.INST2016\\Data"' # cspell: disable-line } @{ - MockParameterName = 'ASLogDir' + MockParameterName = 'ASLogDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Log' - MockExpectedRegEx = '\/ASLOGDIR="C:\\MSOLAP13\.INST2016\\Log"' # cspell: disable-line + MockExpectedRegEx = '\/ASLOGDIR="C:\\MSOLAP13\.INST2016\\Log"' # cspell: disable-line } @{ - MockParameterName = 'ASTempDir' + MockParameterName = 'ASTempDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Temp' - MockExpectedRegEx = '\/ASTEMPDIR="C:\\MSOLAP13\.INST2016\\Temp"' # cspell: disable-line + MockExpectedRegEx = '\/ASTEMPDIR="C:\\MSOLAP13\.INST2016\\Temp"' # cspell: disable-line } @{ - MockParameterName = 'ASCollation' + MockParameterName = 'ASCollation' MockParameterValue = 'latin1_general_100' - MockExpectedRegEx = '\/ASCOLLATION="latin1_general_100"' # cspell: disable-line + MockExpectedRegEx = '\/ASCOLLATION="latin1_general_100"' # cspell: disable-line } @{ - MockParameterName = 'ASServerMode' + MockParameterName = 'ASServerMode' MockParameterValue = 'Multidimensional' - MockExpectedRegEx = '\/ASSERVERMODE=MULTIDIMENSIONAL' # cspell: disable-line + MockExpectedRegEx = '\/ASSERVERMODE=MULTIDIMENSIONAL' # cspell: disable-line } @{ - MockParameterName = 'AsSvcAccount' + MockParameterName = 'AsSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ASSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcPassword' + MockParameterName = 'AsSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcStartupType' + MockParameterName = 'AsSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/ASSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'ASSysAdminAccounts' + MockParameterName = 'ASSysAdminAccounts' MockParameterValue = 'COMPANY\SQL Administrators', 'LocalUser' - MockExpectedRegEx = '\/ASSYSADMINACCOUNTS="COMPANY\\SQL Administrators" "LocalUser"' # cspell: disable-line + MockExpectedRegEx = '\/ASSYSADMINACCOUNTS="COMPANY\\SQL Administrators" "LocalUser"' # cspell: disable-line } @{ - MockParameterName = 'ASProviderMSOLAP' + MockParameterName = 'ASProviderMSOLAP' MockParameterValue = $true - MockExpectedRegEx = '\/ASPROVIDERMSOLAP=1' # cspell: disable-line + MockExpectedRegEx = '\/ASPROVIDERMSOLAP=1' # cspell: disable-line } @{ - MockParameterName = 'BrowserSvcStartupType' + MockParameterName = 'BrowserSvcStartupType' MockParameterValue = 'Manual' - MockExpectedRegEx = '\/BROWSERSVCSTARTUPTYPE="Manual"' # cspell: disable-line + MockExpectedRegEx = '\/BROWSERSVCSTARTUPTYPE="Manual"' # cspell: disable-line } @{ - MockParameterName = 'EnableRanU' + MockParameterName = 'EnableRanU' MockParameterValue = $true - MockExpectedRegEx = '\/ENABLERANU' # cspell: disable-line + MockExpectedRegEx = '\/ENABLERANU' # cspell: disable-line } @{ - MockParameterName = 'InstallSqlDataDir' + MockParameterName = 'InstallSqlDataDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/INSTALLSQLDATADIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSQLDATADIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlBackupDir' + MockParameterName = 'SqlBackupDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Backup' - MockExpectedRegEx = '\/SQLBACKUPDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Backup"' # cspell: disable-line + MockExpectedRegEx = '\/SQLBACKUPDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Backup"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbDir' + MockParameterName = 'SqlTempDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogDir' + MockParameterName = 'SqlTempDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlUserDbDir' + MockParameterName = 'SqlUserDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLUSERDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLUSERDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlUserDbLogDir' + MockParameterName = 'SqlUserDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLUSERDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLUSERDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SecurityMode' + MockParameterName = 'SecurityMode' MockParameterValue = 'SQL' - MockExpectedRegEx = '\/SECURITYMODE="SQL"' # cspell: disable-line + MockExpectedRegEx = '\/SECURITYMODE="SQL"' # cspell: disable-line } @{ - MockParameterName = 'SAPwd' + MockParameterName = 'SAPwd' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlCollation' + MockParameterName = 'SqlCollation' MockParameterValue = 'SQL_Latin1_General_CP1_CI_AS' - MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line + MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcAccount' + MockParameterName = 'SqlSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcPassword' + MockParameterName = 'SqlSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcStartupType' + MockParameterName = 'SqlSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/SQLSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileCount' + MockParameterName = 'SqlTempDbFileCount' MockParameterValue = 8 - MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileSize' + MockParameterName = 'SqlTempDbFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileGrowth' + MockParameterName = 'SqlTempDbFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileSize' + MockParameterName = 'SqlTempDbLogFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileGrowth' + MockParameterName = 'SqlTempDbLogFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcInstantFileInit' + MockParameterName = 'SqlSvcInstantFileInit' MockParameterValue = $true - MockExpectedRegEx = '\/SQLSVCINSTANTFILEINIT=True' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCINSTANTFILEINIT=True' # cspell: disable-line } @{ - MockParameterName = 'SqlMaxDop' + MockParameterName = 'SqlMaxDop' MockParameterValue = 8 - MockExpectedRegEx = '\/SQLMAXDOP=8' # cspell: disable-line + MockExpectedRegEx = '\/SQLMAXDOP=8' # cspell: disable-line } @{ - MockParameterName = 'UseSqlRecommendedMemoryLimits' + MockParameterName = 'UseSqlRecommendedMemoryLimits' MockParameterValue = $true - MockExpectedRegEx = '\/USESQLRECOMMENDEDMEMORYLIMITS' # cspell: disable-line + MockExpectedRegEx = '\/USESQLRECOMMENDEDMEMORYLIMITS' # cspell: disable-line } @{ - MockParameterName = 'SqlMinMemory' + MockParameterName = 'SqlMinMemory' MockParameterValue = 1000 - MockExpectedRegEx = '\/SQLMINMEMORY=1000' # cspell: disable-line + MockExpectedRegEx = '\/SQLMINMEMORY=1000' # cspell: disable-line } @{ - MockParameterName = 'SqlMaxMemory' + MockParameterName = 'SqlMaxMemory' MockParameterValue = 2147483647 - MockExpectedRegEx = '\/SQLMAXMEMORY=2147483647' # cspell: disable-line + MockExpectedRegEx = '\/SQLMAXMEMORY=2147483647' # cspell: disable-line } @{ - MockParameterName = 'FileStreamLevel' + MockParameterName = 'FileStreamLevel' MockParameterValue = 2 - MockExpectedRegEx = '\/FILESTREAMLEVEL=2' # cspell: disable-line + MockExpectedRegEx = '\/FILESTREAMLEVEL=2' # cspell: disable-line } @{ - MockParameterName = 'FileStreamShareName' + MockParameterName = 'FileStreamShareName' MockParameterValue = 'ShareName' - MockExpectedRegEx = '\/FILESTREAMSHARENAME="ShareName"' # cspell: disable-line + MockExpectedRegEx = '\/FILESTREAMSHARENAME="ShareName"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcAccount' + MockParameterName = 'ISSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcPassword' + MockParameterName = 'ISSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcStartupType' + MockParameterName = 'ISSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/ISSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'NpEnabled' + MockParameterName = 'NpEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/NPENABLED=1' # cspell: disable-line + MockExpectedRegEx = '\/NPENABLED=1' # cspell: disable-line } @{ - MockParameterName = 'TcpEnabled' + MockParameterName = 'TcpEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/TCPENABLED=1' # cspell: disable-line + MockExpectedRegEx = '\/TCPENABLED=1' # cspell: disable-line } @{ - MockParameterName = 'RsInstallMode' + MockParameterName = 'RsInstallMode' MockParameterValue = 'FilesOnlyMode' - MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line + MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcAccount' + MockParameterName = 'RSSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/RSSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcPassword' + MockParameterName = 'RSSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcStartupType' + MockParameterName = 'RSSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/RSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ # Argument is reserved for future use, see SQL Server documentation. - MockParameterName = 'MPYCacheDirectory' + MockParameterName = 'MPYCacheDirectory' MockParameterValue = 'C:\Temp' - MockExpectedRegEx = '\/MPYCACHEDIRECTORY="C:\\Temp"' # cspell: disable-line + MockExpectedRegEx = '\/MPYCACHEDIRECTORY="C:\\Temp"' # cspell: disable-line } @{ - MockParameterName = 'MRCacheDirectory' + MockParameterName = 'MRCacheDirectory' MockParameterValue = 'C:\Temp' - MockExpectedRegEx = '\/MRCACHEDIRECTORY="C:\\Temp"' # cspell: disable-line + MockExpectedRegEx = '\/MRCACHEDIRECTORY="C:\\Temp"' # cspell: disable-line } @{ - MockParameterName = 'SqlInstJava' + MockParameterName = 'SqlInstJava' MockParameterValue = $true - MockExpectedRegEx = '\/SQL_INST_JAVA' # cspell: disable-line + MockExpectedRegEx = '\/SQL_INST_JAVA' # cspell: disable-line } @{ - MockParameterName = 'SqlJavaDir' + MockParameterName = 'SqlJavaDir' MockParameterValue = 'C:\Java' - MockExpectedRegEx = '\/SQLJAVADIR="C:\\Java"' # cspell: disable-line + MockExpectedRegEx = '\/SQLJAVADIR="C:\\Java"' # cspell: disable-line } @{ - MockParameterName = 'AzureSubscriptionId' + MockParameterName = 'AzureSubscriptionId' MockParameterValue = '5d19794a-89a4-4f0b-8d4e-58f213ea3546' - MockExpectedRegEx = '\/AZURESUBSCRIPTIONID="5d19794a-89a4-4f0b-8d4e-58f213ea3546"' # cspell: disable-line + MockExpectedRegEx = '\/AZURESUBSCRIPTIONID="5d19794a-89a4-4f0b-8d4e-58f213ea3546"' # cspell: disable-line } @{ - MockParameterName = 'AzureResourceGroup' + MockParameterName = 'AzureResourceGroup' MockParameterValue = 'MyResourceGroup' - MockExpectedRegEx = '\/AZURERESOURCEGROUP="MyResourceGroup"' # cspell: disable-line + MockExpectedRegEx = '\/AZURERESOURCEGROUP="MyResourceGroup"' # cspell: disable-line } @{ - MockParameterName = 'AzureRegion' + MockParameterName = 'AzureRegion' MockParameterValue = 'West-US' - MockExpectedRegEx = '\/AZUREREGION="West-US"' # cspell: disable-line + MockExpectedRegEx = '\/AZUREREGION="West-US"' # cspell: disable-line } @{ - MockParameterName = 'AzureTenantId' + MockParameterName = 'AzureTenantId' MockParameterValue = '5d19794a-89a4-4f0b-8d4e-58f213ea3546' - MockExpectedRegEx = '\/AZURETENANTID="5d19794a-89a4-4f0b-8d4e-58f213ea3546"' # cspell: disable-line + MockExpectedRegEx = '\/AZURETENANTID="5d19794a-89a4-4f0b-8d4e-58f213ea3546"' # cspell: disable-line } @{ - MockParameterName = 'AzureServicePrincipal' + MockParameterName = 'AzureServicePrincipal' MockParameterValue = 'MyServicePrincipal' - MockExpectedRegEx = '\/AZURESERVICEPRINCIPAL="MyServicePrincipal"' # cspell: disable-line + MockExpectedRegEx = '\/AZURESERVICEPRINCIPAL="MyServicePrincipal"' # cspell: disable-line } @{ - MockParameterName = 'AzureServicePrincipalSecret' + MockParameterName = 'AzureServicePrincipalSecret' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AZURESERVICEPRINCIPALSECRET="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/AZURESERVICEPRINCIPALSECRET="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'AzureArcProxy' + MockParameterName = 'AzureArcProxy' MockParameterValue = 'proxy.company.local' - MockExpectedRegEx = '\/AZUREARCPROXY="proxy\.company\.local"' # cspell: disable-line + MockExpectedRegEx = '\/AZUREARCPROXY="proxy\.company\.local"' # cspell: disable-line } @{ - MockParameterName = 'SkipRules' + MockParameterName = 'SkipRules' MockParameterValue = 'Cluster_VerifyForErrors' - MockExpectedRegEx = '\/SKIPRULES="Cluster_VerifyForErrors"' # cspell: disable-line + MockExpectedRegEx = '\/SKIPRULES="Cluster_VerifyForErrors"' # cspell: disable-line } ) { BeforeAll { @@ -621,14 +623,15 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - SqlSysAdminAccounts = 'DOMAIN\User' - Force = $true + Features = 'SqlEngine' + SqlSysAdminAccounts = 'DOMAIN\User' + Force = $true + ErrorAction = 'Stop' } } @@ -652,49 +655,49 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying sensitive parameter ' -ForEach @( @{ - MockParameterName = 'PBEngSvcPassword' + MockParameterName = 'PBEngSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBENGSVCPASSWORD="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCPASSWORD="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'PBDMSSvcPassword' # cspell: disable-line + MockParameterName = 'PBDMSSvcPassword' # cspell: disable-line MockParameterValue = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line - MockExpectedRegEx = '\/PBDMSSVCPASSWORD="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/PBDMSSVCPASSWORD="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'ProductKey' # cspell: disable-line + MockParameterName = 'ProductKey' # cspell: disable-line MockParameterValue = '22222-00000-00000-00000-00000' - MockExpectedRegEx = '\/PID="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/PID="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'AgtSvcPassword' # cspell: disable-line + MockParameterName = 'AgtSvcPassword' # cspell: disable-line MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AGTSVCPASSWORD="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCPASSWORD="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'SAPwd' + MockParameterName = 'SAPwd' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SAPWD="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/SAPWD="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcPassword' + MockParameterName = 'SqlSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SQLSVCPASSWORD="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCPASSWORD="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcPassword' + MockParameterName = 'ISSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ISSVCPASSWORD="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCPASSWORD="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcPassword' + MockParameterName = 'RSSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/RSSVCPASSWORD="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCPASSWORD="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'AzureServicePrincipalSecret' + MockParameterName = 'AzureServicePrincipalSecret' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AZURESERVICEPRINCIPALSECRET="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/AZURESERVICEPRINCIPALSECRET="\*{8}"' # cspell: disable-line } ) { BeforeAll { @@ -704,14 +707,15 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - SqlSysAdminAccounts = 'DOMAIN\User' - Force = $true + Features = 'SqlEngine' + SqlSysAdminAccounts = 'DOMAIN\User' + Force = $true + ErrorAction = 'Stop' } } @@ -764,10 +768,11 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - Upgrade = $true + Upgrade = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' + ErrorAction = 'Stop' } } @@ -812,69 +817,69 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'UpdateEnabled' + MockParameterName = 'UpdateEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line + MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line } @{ - MockParameterName = 'UpdateSource' + MockParameterName = 'UpdateSource' MockParameterValue = '\SqlMedia\Updates' - MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line + MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line } @{ - MockParameterName = 'InstanceDir' + MockParameterName = 'InstanceDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTANCEDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstanceId' + MockParameterName = 'InstanceId' MockParameterValue = 'Instance' - MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line } @{ - MockParameterName = 'ProductKey' + MockParameterName = 'ProductKey' MockParameterValue = '22222-00000-00000-00000-00000' - MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' + MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' } @{ - MockParameterName = 'BrowserSvcStartupType' + MockParameterName = 'BrowserSvcStartupType' MockParameterValue = 'Manual' - MockExpectedRegEx = '\/BROWSERSVCSTARTUPTYPE="Manual"' # cspell: disable-line + MockExpectedRegEx = '\/BROWSERSVCSTARTUPTYPE="Manual"' # cspell: disable-line } @{ - MockParameterName = 'FTUpgradeOption' + MockParameterName = 'FTUpgradeOption' MockParameterValue = 'Reset' - MockExpectedRegEx = '\/FTUPGRADEOPTION="Reset"' # cspell: disable-line + MockExpectedRegEx = '\/FTUPGRADEOPTION="Reset"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcAccount' + MockParameterName = 'ISSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcPassword' + MockParameterName = 'ISSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcStartupType' + MockParameterName = 'ISSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/ISSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'AllowUpgradeForSSRSSharePointMode' + MockParameterName = 'AllowUpgradeForSSRSSharePointMode' MockParameterValue = $true - MockExpectedRegEx = '\/ALLOWUPGRADEFORSSRSSHAREPOINTMODE=True' # cspell: disable-line + MockExpectedRegEx = '\/ALLOWUPGRADEFORSSRSSHAREPOINTMODE=True' # cspell: disable-line } @{ - MockParameterName = 'FailoverClusterRollOwnership' + MockParameterName = 'FailoverClusterRollOwnership' MockParameterValue = 2 - MockExpectedRegEx = '\/FAILOVERCLUSTERROLLOWNERSHIP=2' # cspell: disable-line + MockExpectedRegEx = '\/FAILOVERCLUSTERROLLOWNERSHIP=2' # cspell: disable-line } ) { BeforeAll { @@ -883,12 +888,13 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - Upgrade = $true + Upgrade = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Force = $true + Force = $true + ErrorAction = 'Stop' } } @@ -929,14 +935,14 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - InstallFailoverCluster = $true - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + InstallFailoverCluster = $true + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case. - Features = 'SqlEngine' - SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' - InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' + Features = 'SqlEngine' + SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' + InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' FailoverClusterNetworkName = 'TESTCLU01A' # cspell: disable-line FailoverClusterIPAddresses = @( 'IPv4;172.16.0.0;ClusterNetwork1;172.31.255.255', @@ -944,6 +950,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { 'IPv6;DHCP;ClusterNetwork3' 'IPv4;DHCP;ClusterNetwork4' ) + ErrorAction = 'Stop' } } @@ -1003,19 +1010,20 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $installSqlDscServerParameters = @{ - InstallFailoverCluster = $true - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + InstallFailoverCluster = $true + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' - InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' + Features = 'SqlEngine' + SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' + InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' FailoverClusterNetworkName = 'TESTCLU01A' # cspell: disable-line FailoverClusterIPAddresses = '192.168.0.46' - Force = $true - PBStartPortRange = 16450 - PBEndPortRange = 16460 + Force = $true + PBStartPortRange = 16450 + PBEndPortRange = 16460 + ErrorAction = 'Stop' } } @@ -1033,280 +1041,280 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'UpdateEnabled' + MockParameterName = 'UpdateEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line + MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line } @{ - MockParameterName = 'UpdateSource' + MockParameterName = 'UpdateSource' MockParameterValue = '\SqlMedia\Updates' - MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line + MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line } @{ - MockParameterName = 'InstallSharedDir' + MockParameterName = 'InstallSharedDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTALLSHAREDDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSHAREDDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstallSharedWOWDir' + MockParameterName = 'InstallSharedWOWDir' MockParameterValue = 'C:\Program Files (x86)\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTALLSHAREDWOWDIR="C:\\Program Files \(x86\)\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSHAREDWOWDIR="C:\\Program Files \(x86\)\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstanceDir' + MockParameterName = 'InstanceDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTANCEDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstanceId' + MockParameterName = 'InstanceId' MockParameterValue = 'Instance' - MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcAccount' + MockParameterName = 'PBEngSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcPassword' + MockParameterName = 'PBEngSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcStartupType' + MockParameterName = 'PBEngSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'PBScaleOut' + MockParameterName = 'PBScaleOut' MockParameterValue = $true - MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line + MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line } @{ - MockParameterName = 'ProductKey' + MockParameterName = 'ProductKey' MockParameterValue = '22222-00000-00000-00000-00000' - MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' + MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' } @{ - MockParameterName = 'AgtSvcAccount' + MockParameterName = 'AgtSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'AgtSvcPassword' + MockParameterName = 'AgtSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'ASBackupDir' + MockParameterName = 'ASBackupDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Backup' - MockExpectedRegEx = '\/ASBACKUPDIR="C:\\MSOLAP13\.INST2016\\Backup"' # cspell: disable-line + MockExpectedRegEx = '\/ASBACKUPDIR="C:\\MSOLAP13\.INST2016\\Backup"' # cspell: disable-line } @{ - MockParameterName = 'ASConfigDir' + MockParameterName = 'ASConfigDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Config' - MockExpectedRegEx = '\/ASCONFIGDIR="C:\\MSOLAP13\.INST2016\\Config"' # cspell: disable-line + MockExpectedRegEx = '\/ASCONFIGDIR="C:\\MSOLAP13\.INST2016\\Config"' # cspell: disable-line } @{ - MockParameterName = 'ASDataDir' + MockParameterName = 'ASDataDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Data' - MockExpectedRegEx = '\/ASDATADIR="C:\\MSOLAP13\.INST2016\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/ASDATADIR="C:\\MSOLAP13\.INST2016\\Data"' # cspell: disable-line } @{ - MockParameterName = 'ASLogDir' + MockParameterName = 'ASLogDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Log' - MockExpectedRegEx = '\/ASLOGDIR="C:\\MSOLAP13\.INST2016\\Log"' # cspell: disable-line + MockExpectedRegEx = '\/ASLOGDIR="C:\\MSOLAP13\.INST2016\\Log"' # cspell: disable-line } @{ - MockParameterName = 'ASTempDir' + MockParameterName = 'ASTempDir' MockParameterValue = 'C:\MSOLAP13.INST2016\Temp' - MockExpectedRegEx = '\/ASTEMPDIR="C:\\MSOLAP13\.INST2016\\Temp"' # cspell: disable-line + MockExpectedRegEx = '\/ASTEMPDIR="C:\\MSOLAP13\.INST2016\\Temp"' # cspell: disable-line } @{ - MockParameterName = 'ASCollation' + MockParameterName = 'ASCollation' MockParameterValue = 'latin1_general_100' - MockExpectedRegEx = '\/ASCOLLATION="latin1_general_100"' # cspell: disable-line + MockExpectedRegEx = '\/ASCOLLATION="latin1_general_100"' # cspell: disable-line } @{ - MockParameterName = 'ASServerMode' + MockParameterName = 'ASServerMode' MockParameterValue = 'Multidimensional' - MockExpectedRegEx = '\/ASSERVERMODE=MULTIDIMENSIONAL' # cspell: disable-line + MockExpectedRegEx = '\/ASSERVERMODE=MULTIDIMENSIONAL' # cspell: disable-line } @{ - MockParameterName = 'AsSvcAccount' + MockParameterName = 'AsSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ASSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcPassword' + MockParameterName = 'AsSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcStartupType' + MockParameterName = 'AsSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/ASSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'ASSysAdminAccounts' + MockParameterName = 'ASSysAdminAccounts' MockParameterValue = 'COMPANY\SQL Administrators', 'LocalUser' - MockExpectedRegEx = '\/ASSYSADMINACCOUNTS="COMPANY\\SQL Administrators" "LocalUser"' # cspell: disable-line + MockExpectedRegEx = '\/ASSYSADMINACCOUNTS="COMPANY\\SQL Administrators" "LocalUser"' # cspell: disable-line } @{ - MockParameterName = 'ASProviderMSOLAP' + MockParameterName = 'ASProviderMSOLAP' MockParameterValue = $true - MockExpectedRegEx = '\/ASPROVIDERMSOLAP=1' # cspell: disable-line + MockExpectedRegEx = '\/ASPROVIDERMSOLAP=1' # cspell: disable-line } @{ - MockParameterName = 'SqlBackupDir' + MockParameterName = 'SqlBackupDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Backup' - MockExpectedRegEx = '\/SQLBACKUPDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Backup"' # cspell: disable-line + MockExpectedRegEx = '\/SQLBACKUPDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Backup"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbDir' + MockParameterName = 'SqlTempDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogDir' + MockParameterName = 'SqlTempDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlUserDbDir' + MockParameterName = 'SqlUserDbDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLUSERDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLUSERDBDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SqlUserDbLogDir' + MockParameterName = 'SqlUserDbLogDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' - MockExpectedRegEx = '\/SQLUSERDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line + MockExpectedRegEx = '\/SQLUSERDBLOGDIR="C:\\Program Files\\Microsoft SQL Server\\MSSQL13.INST2016\\MSSQL\\Data"' # cspell: disable-line } @{ - MockParameterName = 'SecurityMode' + MockParameterName = 'SecurityMode' MockParameterValue = 'SQL' - MockExpectedRegEx = '\/SECURITYMODE="SQL"' # cspell: disable-line + MockExpectedRegEx = '\/SECURITYMODE="SQL"' # cspell: disable-line } @{ - MockParameterName = 'SAPwd' + MockParameterName = 'SAPwd' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SAPWD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlCollation' + MockParameterName = 'SqlCollation' MockParameterValue = 'SQL_Latin1_General_CP1_CI_AS' - MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line + MockExpectedRegEx = '\/SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcAccount' + MockParameterName = 'SqlSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcPassword' + MockParameterName = 'SqlSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcStartupType' + MockParameterName = 'SqlSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/SQLSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileCount' + MockParameterName = 'SqlTempDbFileCount' MockParameterValue = 8 - MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILECOUNT=8' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileSize' + MockParameterName = 'SqlTempDbFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbFileGrowth' + MockParameterName = 'SqlTempDbFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileSize' + MockParameterName = 'SqlTempDbLogFileSize' MockParameterValue = 100 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILESIZE=100' # cspell: disable-line } @{ - MockParameterName = 'SqlTempDbLogFileGrowth' + MockParameterName = 'SqlTempDbLogFileGrowth' MockParameterValue = 10 - MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line + MockExpectedRegEx = '\/SQLTEMPDBLOGFILEGROWTH=10' # cspell: disable-line } @{ - MockParameterName = 'FileStreamLevel' + MockParameterName = 'FileStreamLevel' MockParameterValue = 2 - MockExpectedRegEx = '\/FILESTREAMLEVEL=2' # cspell: disable-line + MockExpectedRegEx = '\/FILESTREAMLEVEL=2' # cspell: disable-line } @{ - MockParameterName = 'FileStreamShareName' + MockParameterName = 'FileStreamShareName' MockParameterValue = 'ShareName' - MockExpectedRegEx = '\/FILESTREAMSHARENAME="ShareName"' # cspell: disable-line + MockExpectedRegEx = '\/FILESTREAMSHARENAME="ShareName"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcAccount' + MockParameterName = 'ISSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcPassword' + MockParameterName = 'ISSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcStartupType' + MockParameterName = 'ISSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/ISSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'RsInstallMode' + MockParameterName = 'RsInstallMode' MockParameterValue = 'FilesOnlyMode' - MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line + MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcAccount' + MockParameterName = 'RSSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/RSSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcPassword' + MockParameterName = 'RSSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcStartupType' + MockParameterName = 'RSSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/RSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'SkipRules' + MockParameterName = 'SkipRules' MockParameterValue = 'Cluster_VerifyForErrors' - MockExpectedRegEx = '\/SKIPRULES="Cluster_VerifyForErrors"' # cspell: disable-line + MockExpectedRegEx = '\/SKIPRULES="Cluster_VerifyForErrors"' # cspell: disable-line } @{ - MockParameterName = 'FailoverClusterGroup' + MockParameterName = 'FailoverClusterGroup' MockParameterValue = 'TESTCLU01A' # cspell: disable-line - MockExpectedRegEx = '\/FAILOVERCLUSTERGROUP="TESTCLU01A"' # cspell: disable-line + MockExpectedRegEx = '\/FAILOVERCLUSTERGROUP="TESTCLU01A"' # cspell: disable-line } @{ - MockParameterName = 'FailoverClusterDisks' + MockParameterName = 'FailoverClusterDisks' # This is the failover cluster resource name. MockParameterValue = @( 'SysData' ) - MockExpectedRegEx = '\/FAILOVERCLUSTERDISKS="SysData"' # cspell: disable-line + MockExpectedRegEx = '\/FAILOVERCLUSTERDISKS="SysData"' # cspell: disable-line } @{ - MockParameterName = 'FailoverClusterDisks' + MockParameterName = 'FailoverClusterDisks' # This is the failover cluster resource names. MockParameterValue = @( 'Backup' @@ -1316,7 +1324,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { 'UserData' 'UserLogs' ) - MockExpectedRegEx = '\/FAILOVERCLUSTERDISKS="Backup;SysData;TempDbData;TempDbLogs;UserData;UserLogs"' # cspell: disable-line + MockExpectedRegEx = '\/FAILOVERCLUSTERDISKS="Backup;SysData;TempDbData;TempDbLogs;UserData;UserLogs"' # cspell: disable-line } ) { BeforeAll { @@ -1325,17 +1333,18 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - InstallFailoverCluster = $true - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + InstallFailoverCluster = $true + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' - InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' + Features = 'SqlEngine' + SqlSysAdminAccounts = 'DOMAIN\User', 'COMPANY\SQL Administrators' + InstallSqlDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' FailoverClusterNetworkName = 'TESTCLU01A' # cspell: disable-line FailoverClusterIPAddresses = '192.168.0.46' - Force = $true + Force = $true + ErrorAction = 'Stop' } } @@ -1377,11 +1386,12 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $mockDefaultParameters = @{ PrepareFailoverCluster = $true - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case. - Features = 'SqlEngine' + Features = 'SqlEngine' + ErrorAction = 'Stop' } } @@ -1432,14 +1442,15 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $installSqlDscServerParameters = @{ PrepareFailoverCluster = $true - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - Force = $true - PBStartPortRange = 16450 - PBEndPortRange = 16460 + Features = 'SqlEngine' + Force = $true + PBStartPortRange = 16450 + PBEndPortRange = 16460 + ErrorAction = 'Stop' } } @@ -1457,139 +1468,139 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'UpdateEnabled' + MockParameterName = 'UpdateEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line + MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line } @{ - MockParameterName = 'UpdateSource' + MockParameterName = 'UpdateSource' MockParameterValue = '\SqlMedia\Updates' - MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line + MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line } @{ - MockParameterName = 'InstallSharedDir' + MockParameterName = 'InstallSharedDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTALLSHAREDDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSHAREDDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstallSharedWOWDir' + MockParameterName = 'InstallSharedWOWDir' MockParameterValue = 'C:\Program Files (x86)\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTALLSHAREDWOWDIR="C:\\Program Files \(x86\)\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSHAREDWOWDIR="C:\\Program Files \(x86\)\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstanceDir' + MockParameterName = 'InstanceDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTANCEDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstanceId' + MockParameterName = 'InstanceId' MockParameterValue = 'Instance' - MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcAccount' + MockParameterName = 'PBEngSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcPassword' + MockParameterName = 'PBEngSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcStartupType' + MockParameterName = 'PBEngSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'PBScaleOut' + MockParameterName = 'PBScaleOut' MockParameterValue = $true - MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line + MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line } @{ - MockParameterName = 'ProductKey' + MockParameterName = 'ProductKey' MockParameterValue = '22222-00000-00000-00000-00000' - MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' + MockExpectedRegEx = '\/PID="22222-00000-00000-00000-00000"' } @{ - MockParameterName = 'AgtSvcAccount' + MockParameterName = 'AgtSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'AgtSvcPassword' + MockParameterName = 'AgtSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcAccount' + MockParameterName = 'AsSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ASSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcPassword' + MockParameterName = 'AsSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcAccount' + MockParameterName = 'SqlSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcPassword' + MockParameterName = 'SqlSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'FileStreamLevel' + MockParameterName = 'FileStreamLevel' MockParameterValue = 2 - MockExpectedRegEx = '\/FILESTREAMLEVEL=2' # cspell: disable-line + MockExpectedRegEx = '\/FILESTREAMLEVEL=2' # cspell: disable-line } @{ - MockParameterName = 'FileStreamShareName' + MockParameterName = 'FileStreamShareName' MockParameterValue = 'ShareName' - MockExpectedRegEx = '\/FILESTREAMSHARENAME="ShareName"' # cspell: disable-line + MockExpectedRegEx = '\/FILESTREAMSHARENAME="ShareName"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcAccount' + MockParameterName = 'ISSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcPassword' + MockParameterName = 'ISSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcStartupType' + MockParameterName = 'ISSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/ISSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'RsInstallMode' + MockParameterName = 'RsInstallMode' MockParameterValue = 'FilesOnlyMode' - MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line + MockExpectedRegEx = '\/RSINSTALLMODE="FilesOnlyMode"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcAccount' + MockParameterName = 'RSSvcAccount' MockParameterValue = 'DOMAIN\ServiceAccount$' - MockExpectedRegEx = '\/RSSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCACCOUNT="DOMAIN\\ServiceAccount\$"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcPassword' + MockParameterName = 'RSSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcStartupType' + MockParameterName = 'RSSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/RSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } ) { BeforeAll { @@ -1599,12 +1610,13 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $mockDefaultParameters = @{ PrepareFailoverCluster = $true - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - Force = $true + Features = 'SqlEngine' + Force = $true + ErrorAction = 'Stop' } } @@ -1653,7 +1665,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $mockDefaultParameters = @{ ConfigurationFile = 'C:\MyConfig.ini' - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' } } @@ -1696,29 +1708,29 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'AgtSvcPassword' + MockParameterName = 'AgtSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/AGTSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'AsSvcPassword' + MockParameterName = 'AsSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ASSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'SqlSvcPassword' + MockParameterName = 'SqlSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/SQLSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'ISSvcPassword' + MockParameterName = 'ISSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/ISSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'RSSvcPassword' + MockParameterName = 'RSSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/RSSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } ) { BeforeAll { @@ -1728,8 +1740,9 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $mockDefaultParameters = @{ ConfigurationFile = 'C:\MyConfig.ini' - MediaPath = '\SqlMedia' - Force = $true + MediaPath = '\SqlMedia' + Force = $true + ErrorAction = 'Stop' } } @@ -1770,11 +1783,12 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - EditionUpgrade = $true + EditionUpgrade = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' - ProductKey = '22222-00000-00000-00000-00000' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' + ProductKey = '22222-00000-00000-00000-00000' + ErrorAction = 'Stop' } } @@ -1821,9 +1835,9 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'SkipRules' + MockParameterName = 'SkipRules' MockParameterValue = 'Cluster_VerifyForErrors' - MockExpectedRegEx = '\/SKIPRULES="Cluster_VerifyForErrors"' # cspell: disable-line + MockExpectedRegEx = '\/SKIPRULES="Cluster_VerifyForErrors"' # cspell: disable-line } ) { BeforeAll { @@ -1832,12 +1846,13 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - EditionUpgrade = $true + EditionUpgrade = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' - ProductKey = 22222-00000-00000-00000-00000 - Force = $true + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' + ProductKey = 22222 - 00000 - 00000 - 00000 - 00000 + Force = $true + ErrorAction = 'Stop' } } @@ -1878,12 +1893,13 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - PrepareImage = $true + PrepareImage = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' # Intentionally using both upper- and lower-case. - Features = 'SqlEngine' - InstanceId = 'Instance' + Features = 'SqlEngine' + InstanceId = 'Instance' + ErrorAction = 'Stop' } } @@ -1930,54 +1946,54 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'UpdateEnabled' + MockParameterName = 'UpdateEnabled' MockParameterValue = $true - MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line + MockExpectedRegEx = '\/UPDATEENABLED=True' # cspell: disable-line } @{ - MockParameterName = 'UpdateSource' + MockParameterName = 'UpdateSource' MockParameterValue = '\SqlMedia\Updates' - MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line + MockExpectedRegEx = '\/UPDATESOURCE="\\SqlMedia\\Updates"' # cspell: disable-line } @{ - MockParameterName = 'InstallSharedDir' + MockParameterName = 'InstallSharedDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTALLSHAREDDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTALLSHAREDDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstanceDir' + MockParameterName = 'InstanceDir' MockParameterValue = 'C:\Program Files\Microsoft SQL Server' - MockExpectedRegEx = '\/INSTANCEDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEDIR="C:\\Program Files\\Microsoft SQL Server"' # cspell: disable-line } @{ - MockParameterName = 'InstanceId' + MockParameterName = 'InstanceId' MockParameterValue = 'Instance' - MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line + MockExpectedRegEx = '\/INSTANCEID="Instance"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcAccount' + MockParameterName = 'PBEngSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcPassword' + MockParameterName = 'PBEngSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcStartupType' + MockParameterName = 'PBEngSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'PBScaleOut' + MockParameterName = 'PBScaleOut' MockParameterValue = $true - MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line + MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line } ) { BeforeAll { @@ -1986,13 +2002,14 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - PrepareImage = $true + PrepareImage = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' # Intentionally using both upper- and lower-case. - Features = 'SqlEngine' - InstanceId = 'Instance' - Force = $true + Features = 'SqlEngine' + InstanceId = 'Instance' + Force = $true + ErrorAction = 'Stop' } } @@ -2033,15 +2050,16 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - Install = $true - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - AzureSubscriptionId = '5d19794a-89a4-4f0b-8d4e-58f213ea3546' - AzureResourceGroup = 'MyResourceGroup' - AzureRegion = 'West-US' - AzureTenantId = '7e52fb9e-6aad-426c-98c4-7d2f11f7e94b' - AzureServicePrincipal = 'MyServicePrincipal' + Install = $true + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + AzureSubscriptionId = '5d19794a-89a4-4f0b-8d4e-58f213ea3546' + AzureResourceGroup = 'MyResourceGroup' + AzureRegion = 'West-US' + AzureTenantId = '7e52fb9e-6aad-426c-98c4-7d2f11f7e94b' + AzureServicePrincipal = 'MyServicePrincipal' AzureServicePrincipalSecret = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line + ErrorAction = 'Stop' } } @@ -2058,7 +2076,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $ArgumentList | Should -MatchExactly '\/AZURETENANTID="7e52fb9e-6aad-426c-98c4-7d2f11f7e94b"' # cspell: disable-line $ArgumentList | Should -MatchExactly '\/AZURESERVICEPRINCIPAL="MyServicePrincipal"' # cspell: disable-line $ArgumentList | Should -MatchExactly '\/AZURESERVICEPRINCIPALSECRET="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line - $ArgumentList | Should -MatchExactly '\/FEATURES=AZUREEXTENSION' + $ArgumentList | Should -MatchExactly '\/FEATURES=AZUREEXTENSION' # cspell: disable-line # Return $true if none of the above throw. $true @@ -2079,7 +2097,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { $ArgumentList | Should -MatchExactly '\/AZURETENANTID="7e52fb9e-6aad-426c-98c4-7d2f11f7e94b"' # cspell: disable-line $ArgumentList | Should -MatchExactly '\/AZURESERVICEPRINCIPAL="MyServicePrincipal"' # cspell: disable-line $ArgumentList | Should -MatchExactly '\/AZURESERVICEPRINCIPALSECRET="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line - $ArgumentList | Should -MatchExactly '\/FEATURES=AZUREEXTENSION' + $ArgumentList | Should -MatchExactly '\/FEATURES=AZUREEXTENSION' # cspell: disable-line # Return $true if none of the above throw. $true @@ -2098,9 +2116,9 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'AzureArcProxy' + MockParameterName = 'AzureArcProxy' MockParameterValue = 'proxy.company.local' - MockExpectedRegEx = '\/AZUREARCPROXY="proxy\.company\.local"' # cspell: disable-line + MockExpectedRegEx = '\/AZUREARCPROXY="proxy\.company\.local"' # cspell: disable-line } ) { BeforeAll { @@ -2109,16 +2127,17 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - Install = $true - AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - AzureSubscriptionId = '5d19794a-89a4-4f0b-8d4e-58f213ea3546' - AzureResourceGroup = 'MyResourceGroup' - AzureRegion = 'West-US' - AzureTenantId = '7e52fb9e-6aad-426c-98c4-7d2f11f7e94b' - AzureServicePrincipal = 'MyServicePrincipal' + Install = $true + AcceptLicensingTerms = $true + MediaPath = '\SqlMedia' + AzureSubscriptionId = '5d19794a-89a4-4f0b-8d4e-58f213ea3546' + AzureResourceGroup = 'MyResourceGroup' + AzureRegion = 'West-US' + AzureTenantId = '7e52fb9e-6aad-426c-98c4-7d2f11f7e94b' + AzureServicePrincipal = 'MyServicePrincipal' AzureServicePrincipalSecret = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line - Force = $true + Force = $true + ErrorAction = 'Stop' } } @@ -2160,10 +2179,11 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } $mockDefaultParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - Role = 'SPI_AS_NewFarm' + MediaPath = '\SqlMedia' + Role = 'SPI_AS_NewFarm' + ErrorAction = 'Stop' } } @@ -2208,24 +2228,24 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'FarmAccount' + MockParameterName = 'FarmAccount' MockParameterValue = 'DOMAIN\User' - MockExpectedRegEx = '\/FARMACCOUNT="DOMAIN\\User"' # cspell: disable-line + MockExpectedRegEx = '\/FARMACCOUNT="DOMAIN\\User"' # cspell: disable-line } @{ - MockParameterName = 'FarmPassword' + MockParameterName = 'FarmPassword' MockParameterValue = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line - MockExpectedRegEx = '\/FARMPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/FARMPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'Passphrase' + MockParameterName = 'Passphrase' MockParameterValue = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line - MockExpectedRegEx = '\/PASSPHRASE="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PASSPHRASE="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'FarmAdminiPort' # cspell: disable-line + MockParameterName = 'FarmAdminiPort' # cspell: disable-line MockParameterValue = '18000' - MockExpectedRegEx = '\/FARMADMINIPORT=18000' # cspell: disable-line + MockExpectedRegEx = '\/FARMADMINIPORT=18000' # cspell: disable-line } ) { BeforeAll { @@ -2234,11 +2254,12 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } $mockDefaultParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - Role = 'SPI_AS_NewFarm' - Force = $true + MediaPath = '\SqlMedia' + Role = 'SPI_AS_NewFarm' + Force = $true + ErrorAction = 'Stop' } } @@ -2262,14 +2283,14 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying sensitive parameter ' -ForEach @( @{ - MockParameterName = 'FarmPassword' + MockParameterName = 'FarmPassword' MockParameterValue = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line - MockExpectedRegEx = '\/FARMPASSWORD="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/FARMPASSWORD="\*{8}"' # cspell: disable-line } @{ - MockParameterName = 'Passphrase' + MockParameterName = 'Passphrase' MockParameterValue = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line - MockExpectedRegEx = '\/PASSPHRASE="\*{8}"' # cspell: disable-line + MockExpectedRegEx = '\/PASSPHRASE="\*{8}"' # cspell: disable-line } ) { BeforeAll { @@ -2279,11 +2300,12 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } $mockDefaultParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - Role = 'SPI_AS_NewFarm' - Force = $true + MediaPath = '\SqlMedia' + Role = 'SPI_AS_NewFarm' + Force = $true + ErrorAction = 'Stop' } } @@ -2326,10 +2348,11 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } $mockDefaultParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - Role = 'AllFeatures_WithDefaults' + MediaPath = '\SqlMedia' + Role = 'AllFeatures_WithDefaults' + ErrorAction = 'Stop' } } @@ -2374,14 +2397,14 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'Features' # cspell: disable-line + MockParameterName = 'Features' # cspell: disable-line MockParameterValue = 'SqlEngine', 'RS' - MockExpectedRegEx = '\/FEATURES=SQLENGINE,RS' # cspell: disable-line + MockExpectedRegEx = '\/FEATURES=SQLENGINE,RS' # cspell: disable-line } @{ - MockParameterName = 'AddCurrentUserAsSqlAdmin' # cspell: disable-line + MockParameterName = 'AddCurrentUserAsSqlAdmin' # cspell: disable-line MockParameterValue = $true - MockExpectedRegEx = '\/ADDCURRENTUSERASSQLADMIN=True' # cspell: disable-line + MockExpectedRegEx = '\/ADDCURRENTUSERASSQLADMIN=True' # cspell: disable-line } ) { BeforeAll { @@ -2390,11 +2413,12 @@ Describe 'Install-SqlDscServer' -Tag 'Public' { } $mockDefaultParameters = @{ - Install = $true + Install = $true AcceptLicensingTerms = $true - MediaPath = '\SqlMedia' - Role = 'AllFeatures_WithDefaults' - Force = $true + MediaPath = '\SqlMedia' + Role = 'AllFeatures_WithDefaults' + Force = $true + ErrorAction = 'Stop' } } diff --git a/tests/Unit/Public/Remove-SqlDscNode.Tests.ps1 b/tests/Unit/Public/Remove-SqlDscNode.Tests.ps1 index 343d845db..e8230151d 100644 --- a/tests/Unit/Public/Remove-SqlDscNode.Tests.ps1 +++ b/tests/Unit/Public/Remove-SqlDscNode.Tests.ps1 @@ -50,7 +50,7 @@ AfterAll { Describe 'Remove-SqlDscNode' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ - MockParameterSetName = '__AllParameterSets' + MockParameterSetName = '__AllParameterSets' # cSpell: disable-next MockExpectedParameters = '[-MediaPath] [-InstanceName] [[-Timeout] ] [-ConfirmIPDependencyChange] [-Force] [-WhatIf] [-Confirm] []' } @@ -61,11 +61,11 @@ Describe 'Remove-SqlDscNode' -Tag 'Public' { } | Select-Object -Property @( @{ - Name = 'ParameterSetName' + Name = 'ParameterSetName' Expression = { $_.Name } }, @{ - Name = 'ParameterListAsString' + Name = 'ParameterListAsString' Expression = { $_.ToString() } } ) @@ -92,8 +92,9 @@ Describe 'Remove-SqlDscNode' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' InstanceName = 'INSTANCE' + ErrorAction = 'Stop' } } @@ -136,9 +137,9 @@ Describe 'Remove-SqlDscNode' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'ConfirmIPDependencyChange' + MockParameterName = 'ConfirmIPDependencyChange' MockParameterValue = $true - MockExpectedRegEx = '\/CONFIRMIPDEPENDENCYCHANGE=1' # cspell: disable-line + MockExpectedRegEx = '\/CONFIRMIPDEPENDENCYCHANGE=1' # cspell: disable-line } ) { BeforeAll { @@ -147,9 +148,10 @@ Describe 'Remove-SqlDscNode' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' InstanceName = 'INSTANCE' - Force = $true + Force = $true + ErrorAction = 'Stop' } } diff --git a/tests/Unit/Public/Repair-SqlDscServer.Tests.ps1 b/tests/Unit/Public/Repair-SqlDscServer.Tests.ps1 index 50c0602fd..220e00e3b 100644 --- a/tests/Unit/Public/Repair-SqlDscServer.Tests.ps1 +++ b/tests/Unit/Public/Repair-SqlDscServer.Tests.ps1 @@ -50,7 +50,7 @@ AfterAll { Describe 'Repair-SqlDscServer' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ - MockParameterSetName = '__AllParameterSets' + MockParameterSetName = '__AllParameterSets' # cSpell: disable-next MockExpectedParameters = '[-MediaPath] [-InstanceName] [-Features] [[-PBEngSvcAccount] ] [[-PBEngSvcPassword] ] [[-PBEngSvcStartupType] ] [[-PBStartPortRange] ] [[-PBEndPortRange] ] [[-Timeout] ] [-Enu] [-PBScaleOut] [-Force] [-WhatIf] [-Confirm] []' } @@ -61,11 +61,11 @@ Describe 'Repair-SqlDscServer' -Tag 'Public' { } | Select-Object -Property @( @{ - Name = 'ParameterSetName' + Name = 'ParameterSetName' Expression = { $_.Name } }, @{ - Name = 'ParameterListAsString' + Name = 'ParameterListAsString' Expression = { $_.ToString() } } ) @@ -92,10 +92,11 @@ Describe 'Repair-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' + Features = 'SqlEngine' + ErrorAction = 'Stop' } } @@ -145,13 +146,14 @@ Describe 'Repair-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $repairSqlDscServerParameters = @{ - MediaPath = '\SqlMedia' - InstanceName = 'INSTANCE' + MediaPath = '\SqlMedia' + InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - Force = $true + Features = 'SqlEngine' + Force = $true PBStartPortRange = 16450 - PBEndPortRange = 16460 + PBEndPortRange = 16460 + ErrorAction = 'Stop' } } @@ -169,29 +171,29 @@ Describe 'Repair-SqlDscServer' -Tag 'Public' { Context 'When specifying optional parameter ' -ForEach @( @{ - MockParameterName = 'Enu' + MockParameterName = 'Enu' MockParameterValue = $true - MockExpectedRegEx = '\/ENU\s*' + MockExpectedRegEx = '\/ENU\s*' } @{ - MockParameterName = 'PBEngSvcAccount' + MockParameterName = 'PBEngSvcAccount' MockParameterValue = 'NT Authority\NETWORK SERVICE' - MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCACCOUNT="NT Authority\\NETWORK SERVICE"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcPassword' + MockParameterName = 'PBEngSvcPassword' MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line - MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCPASSWORD="jT7ELPbD2GGuvLmjABDL"' # cspell: disable-line } @{ - MockParameterName = 'PBEngSvcStartupType' + MockParameterName = 'PBEngSvcStartupType' MockParameterValue = 'Automatic' - MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line + MockExpectedRegEx = '\/PBENGSVCSTARTUPTYPE="Automatic"' # cspell: disable-line } @{ - MockParameterName = 'PBScaleOut' + MockParameterName = 'PBScaleOut' MockParameterValue = $true - MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line + MockExpectedRegEx = '\/PBSCALEOUT=True' # cspell: disable-line } ) { BeforeAll { @@ -200,11 +202,12 @@ Describe 'Repair-SqlDscServer' -Tag 'Public' { } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case in the value. - Features = 'SqlEngine' - Force = $true + Features = 'SqlEngine' + Force = $true + ErrorAction = 'Stop' } } diff --git a/tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1 b/tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1 new file mode 100644 index 000000000..faa3bdd0d --- /dev/null +++ b/tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1 @@ -0,0 +1,220 @@ +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'because ConvertTo-SecureString is used to simplify the tests.')] +param () + +BeforeDiscovery { + try + { + if (-not (Get-Module -Name 'DscResource.Test')) + { + # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) + { + # Redirect all streams to $null, except the error stream (stream 2) + & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 2>&1 4>&1 5>&1 6>&1 > $null + } + + # If the dependencies has not been resolved, this will throw an error. + Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' + } + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.' + } +} + +BeforeAll { + $script:dscModuleName = 'SqlServerDsc' + + $env:SqlServerDscCI = $true + + Import-Module -Name $script:dscModuleName + + $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:dscModuleName + $PSDefaultParameterValues['Mock:ModuleName'] = $script:dscModuleName + $PSDefaultParameterValues['Should:ModuleName'] = $script:dscModuleName +} + +AfterAll { + $PSDefaultParameterValues.Remove('InModuleScope:ModuleName') + $PSDefaultParameterValues.Remove('Mock:ModuleName') + $PSDefaultParameterValues.Remove('Should:ModuleName') + + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force + + Remove-Item -Path 'env:SqlServerDscCI' +} + +Describe 'Save-SqlDscSqlServerMediaFile' -Tag 'Public' { + It 'Should have the correct parameters in parameter set ' -ForEach @( + @{ + MockParameterSetName = '__AllParameterSets' + # cSpell: disable-next + MockExpectedParameters = '[-Url] [-DestinationPath] [[-FileName] ] [[-Language] ] [-Quiet] [-Force] [-WhatIf] [-Confirm] []' + } + ) { + $result = (Get-Command -Name 'Save-SqlDscSqlServerMediaFile').ParameterSets | + Where-Object -FilterScript { + $_.Name -eq $mockParameterSetName + } | + Select-Object -Property @( + @{ + Name = 'ParameterSetName' + Expression = { $_.Name } + }, + @{ + Name = 'ParameterListAsString' + Expression = { $_.ToString() } + } + ) + + $result.ParameterSetName | Should -Be $MockParameterSetName + $result.ParameterListAsString | Should -Be $MockExpectedParameters + } + + BeforeAll { + # Mock the Invoke-WebRequest cmdlet to prevent actual downloads during testing + Mock -CommandName Invoke-WebRequest + + # Mock the Start-Process cmdlet to prevent actual process execution during testing + Mock -CommandName Start-Process + + # Mock the Remove-Item cmdlet to prevent actual file deletion during testing + Mock -CommandName Remove-Item + + # Mock the Rename-Item cmdlet to prevent actual file renaming during testing + Mock -CommandName Rename-Item + + <# + Mock the Get-Item cmdlet to simulate both that there is no presence + of a file in the destination path (Count property), and then that we + successfully downloaded a file to the destination path (FullName property). + #> + Mock -CommandName Get-Item -MockWith { + return @{ + Count = 0 + FullName = 'C:\Temp\media.iso' + } + } + + # Define parameters for the function + $Url = 'http://example.com/media.iso' + $DestinationPath = 'C:\Temp' + } + + Context 'When the URL does not end with .exe' { + It 'Should call Invoke-WebRequest to download the media file' { + Save-SqlDscSqlServerMediaFile -Url $Url -DestinationPath $DestinationPath -Confirm:$false + + Should -Invoke -CommandName Invoke-WebRequest -Exactly -Times 1 -Scope It + } + } + + Context 'When the URL ends with .exe' { + BeforeAll { + $Url = "$Url.exe" + + Mock -CommandName Test-Path -MockWith { + return $false + } -ParameterFilter { + $Path -eq (Join-Path -Path $DestinationPath -ChildPath 'media.iso') + } + } + + It 'Should call Invoke-WebRequest to download the executable file' { + Save-SqlDscSqlServerMediaFile -Url $Url -DestinationPath $DestinationPath -Confirm:$false + + Should -Invoke -CommandName Invoke-WebRequest -Exactly -Times 1 -Scope It + } + + It 'Should call Start-Process to initiate download using the downloaded executable file' { + Save-SqlDscSqlServerMediaFile -Url $Url -DestinationPath $DestinationPath -Confirm:$false + + Should -Invoke -CommandName Start-Process -Exactly -Times 1 -Scope It + } + + It 'Should call Remove-Item to remove the executable file' { + Save-SqlDscSqlServerMediaFile -Url $Url -DestinationPath $DestinationPath -Confirm:$false + + Should -Invoke -CommandName Remove-Item -Exactly -Times 1 -Scope It + } + + It 'Should call Rename-Item to rename the downloaded ISO file to the specified name' { + Save-SqlDscSqlServerMediaFile -Url $Url -DestinationPath $DestinationPath -Confirm:$false + + Should -Invoke -CommandName Rename-Item -Exactly -Times 1 -Scope It + } + } + + Context 'When file is already present and should be overridden' { + BeforeAll { + Mock -CommandName Test-Path -MockWith { + return $true + } -ParameterFilter { + $Path -eq (Join-Path -Path $DestinationPath -ChildPath 'media.iso') + } + } + + It 'Should remove the existing file' { + Mock -CommandName Invoke-WebRequest + Mock -CommandName Remove-Item + + Save-SqlDscSqlServerMediaFile -Url 'https://example.com/media.iso' -DestinationPath 'C:\Temp' -Force + + Should -Invoke -CommandName Invoke-WebRequest -Exactly -Times 1 -Scope It + Should -Invoke -CommandName Remove-Item -Exactly -Times 1 -Scope It + } + } + + Context 'When the Force parameter is used' { + It 'Should force the download of the media file' { + Mock -CommandName Invoke-WebRequest + + Save-SqlDscSqlServerMediaFile -Url 'https://example.com/media.iso' -DestinationPath 'C:\Temp' -Force + + Should -Invoke -CommandName Invoke-WebRequest -Exactly -Times 1 -Scope It + } + } + + Context 'When the Quiet parameter is used' { + It 'Should download the media file silently' { + Mock -CommandName Invoke-WebRequest + + Save-SqlDscSqlServerMediaFile -Url 'https://example.com/media.iso' -DestinationPath 'C:\Temp' -Quiet -Confirm:$false + + Should -Invoke -CommandName Invoke-WebRequest -Exactly -Times 1 -Scope It + } + } + + Context 'When the Language parameter is used' { + It 'Should download the media file in the specified language' { + Mock -CommandName Invoke-WebRequest + Mock -CommandName Start-Process + + Save-SqlDscSqlServerMediaFile -Url 'https://example.com/media.exe' -DestinationPath 'C:\Temp' -Language 'fr-FR' -Confirm:$false + + Should -Invoke -CommandName Invoke-WebRequest -Times 1 -Exactly + Should -Invoke -CommandName Start-Process -Times 1 -Exactly + } + } + + Context 'When there is already an ISO file in the destination path' { + BeforeAll { + Mock -CommandName Get-Item -MockWith { + return @{ + Count = 1 + } + } + } + + It 'Should throw the correct error' { + $mockErrorMessage = InModuleScope -ScriptBlock { + $script:localizedData.SqlServerMediaFile_Save_InvalidDestinationFolder + } + + { Save-SqlDscSqlServerMediaFile -Url $Url -DestinationPath $DestinationPath -Confirm:$false } | Should -Throw $mockErrorMessage + } + } +} diff --git a/tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1 b/tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1 index cbebcdee5..19fa0ab4a 100644 --- a/tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1 +++ b/tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1 @@ -50,7 +50,7 @@ AfterAll { Describe 'Uninstall-SqlDscServer' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ - MockParameterSetName = '__AllParameterSets' + MockParameterSetName = '__AllParameterSets' # cSpell: disable-next MockExpectedParameters = '[-MediaPath] [-InstanceName] [[-Features] ] [[-Timeout] ] [-Force] [-SuppressPrivacyStatementNotice] [-WhatIf] [-Confirm] []' } @@ -61,11 +61,11 @@ Describe 'Uninstall-SqlDscServer' -Tag 'Public' { } | Select-Object -Property @( @{ - Name = 'ParameterSetName' + Name = 'ParameterSetName' Expression = { $_.Name } }, @{ - Name = 'ParameterListAsString' + Name = 'ParameterListAsString' Expression = { $_.ToString() } } ) @@ -85,17 +85,18 @@ Describe 'Uninstall-SqlDscServer' -Tag 'Public' { } } - Context 'When specifying only mandatory parameters' { + Context 'When specifying only mandatory parameters' { BeforeAll { Mock -CommandName Start-SqlSetupProcess -MockWith { return 0 } -RemoveParameterValidation 'FilePath' $mockDefaultParameters = @{ - MediaPath = '\SqlMedia' + MediaPath = '\SqlMedia' InstanceName = 'INSTANCE' # Intentionally using both upper- and lower-case. - Features = 'SqlEngine' + Features = 'SqlEngine' + ErrorAction = 'Stop' } }