From ff04c9e282e0ad67e25b774c18e0b33e1647ea78 Mon Sep 17 00:00:00 2001 From: Josh King Date: Thu, 20 Jul 2023 09:37:27 -0400 Subject: [PATCH] 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'