From ff04c9e282e0ad67e25b774c18e0b33e1647ea78 Mon Sep 17 00:00:00 2001 From: Josh King Date: Thu, 20 Jul 2023 09:37:27 -0400 Subject: [PATCH 1/2] SqlLogin: Attempting to disable and already disabled login throws an error #1952 --- source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 4 ++-- tests/Unit/SqlServerDsc.Common.Tests.ps1 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 9201acd1c..5a18c3a89 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -621,7 +621,7 @@ function Connect-SQL $newObjectParameters = @{ TypeName = 'System.Management.Automation.ErrorRecord' ArgumentList = @( - $invalidOperationException.ToString(), + $invalidOperationException, 'CS0001', 'InvalidOperation', $databaseEngineInstance @@ -642,7 +642,7 @@ function Connect-SQL $newObjectParameters = @{ TypeName = 'System.Management.Automation.ErrorRecord' ArgumentList = @( - $invalidOperationException.ToString(), + $invalidOperationException, 'CS0002', 'InvalidOperation', $databaseEngineInstance diff --git a/tests/Unit/SqlServerDsc.Common.Tests.ps1 b/tests/Unit/SqlServerDsc.Common.Tests.ps1 index 05a53b90a..5c0853eb9 100644 --- a/tests/Unit/SqlServerDsc.Common.Tests.ps1 +++ b/tests/Unit/SqlServerDsc.Common.Tests.ps1 @@ -2663,7 +2663,7 @@ Describe 'SqlServerDsc.Common\Connect-SQL' -Tag 'ConnectSql' { $mockErrorMessage = $mockLocalizedString -f 'localhost' { Connect-SQL -ServerName 'localhost' -ErrorAction 'Stop' } | - Should -Throw -ExpectedMessage ('System.InvalidOperationException: {0}*' -f $mockErrorMessage) + Should -Throw -ExpectedMessage $mockErrorMessage Should -Invoke -CommandName New-Object -ParameterFilter { $TypeName -eq 'Microsoft.SqlServer.Management.Smo.Server' From f969e6b45512ebf2866cde8596e41b883fc6eb8e Mon Sep 17 00:00:00 2001 From: Josh King Date: Thu, 20 Jul 2023 10:41:25 -0400 Subject: [PATCH 2/2] Adding reference to issue to CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a0f3cb8f..2418a7dc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SqlWindowsFirewall - Fix duplication of SQL Server Browser Firewall Rule when deploying Analysis Services feature ([issue #1942](https://github.com/dsccommunity/SqlServerDsc/issues/1942)). +- SqlLogin + - Attempting to disable and already disabled login throws an error ([issue #1952](https://github.com/dsccommunity/SqlServerDsc/issues/1952)) ## [16.3.1] - 2023-05-06