From b4e9a18e1bc96c453d0707efa4192f032a70c056 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 11 Feb 2023 14:46:30 +0100 Subject: [PATCH 01/13] `Get-SqlDscAudit`: `Name` no longer mandatory --- CHANGELOG.md | 3 ++ source/Public/Get-SqlDscAudit.ps1 | 36 ++++++++++++------- tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 | 38 +++++++++++++++++++++ 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 486e4d68e..2a874404e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -255,6 +255,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Get-TargetResource` was updated to always return an array for parameter `TraceFlags`, `TraceFlagsToInclude`, and `TraceFlagsToInclude`. _The last_ _two properties will always return an empty array._ +- `Get-SqlDscAudit` + - The parameter `Name` is no longer mandatory. When left out all the current + audits are returned. ### Fixed diff --git a/source/Public/Get-SqlDscAudit.ps1 b/source/Public/Get-SqlDscAudit.ps1 index 77f82a3c3..70c21533a 100644 --- a/source/Public/Get-SqlDscAudit.ps1 +++ b/source/Public/Get-SqlDscAudit.ps1 @@ -29,8 +29,9 @@ #> function Get-SqlDscAudit { + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', '', Justification = 'Because the rule does not understands that the command returns [System.String[]] when using , (comma) in the return statement')] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the rule does not yet support parsing the code when a parameter type is not available. The ScriptAnalyzer rule UseSyntacticallyCorrectExamples will always error in the editor due to https://github.com/indented-automation/Indented.ScriptAnalyzerRules/issues/8.')] - [OutputType([Microsoft.SqlServer.Management.Smo.Audit])] + [OutputType([Microsoft.SqlServer.Management.Smo.Audit[]])] [CmdletBinding()] param ( @@ -38,7 +39,7 @@ function Get-SqlDscAudit [Microsoft.SqlServer.Management.Smo.Server] $ServerObject, - [Parameter(Mandatory = $true)] + [Parameter()] [System.String] $Name, @@ -55,22 +56,31 @@ function Get-SqlDscAudit $ServerObject.Audits.Refresh() } - $auditObject = $ServerObject.Audits[$Name] + $auditObject = @() - if (-not $AuditObject) + if ($PSBoundParameters.ContainsKey('Name')) { - $missingAuditMessage = $script:localizedData.Audit_Missing -f $Name + $auditObject = $ServerObject.Audits[$Name] - $writeErrorParameters = @{ - Message = $missingAuditMessage - Category = 'InvalidOperation' - ErrorId = 'GSDA0001' # cspell: disable-line - TargetObject = $Name - } + if (-not $AuditObject) + { + $missingAuditMessage = $script:localizedData.Audit_Missing -f $Name + + $writeErrorParameters = @{ + Message = $missingAuditMessage + Category = 'InvalidOperation' + ErrorId = 'GSDA0001' # cspell: disable-line + TargetObject = $Name + } - Write-Error @writeErrorParameters + Write-Error @writeErrorParameters + } + } + else + { + $auditObject = $ServerObject.Audits } - return $auditObject + return , [Microsoft.SqlServer.Management.Smo.Audit[]] $auditObject } } diff --git a/tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 b/tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 index 1d4bb6896..392e04259 100644 --- a/tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 +++ b/tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 @@ -146,4 +146,42 @@ Describe 'Get-SqlDscAudit' -Tag 'Public' { } } } + + Context 'When getting all current audits' { + BeforeAll { + $mockServerObject = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.Server' + $mockServerObject.InstanceName = 'TestInstance' + + $mockServerObject = $mockServerObject | + Add-Member -MemberType 'ScriptProperty' -Name 'Audits' -Value { + return @( + ( + New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.Audit' -ArgumentList @( + $mockServerObject, + 'Log1' + ) + ), + ( + New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.Audit' -ArgumentList @( + $mockServerObject, + 'Log2' + ) + ) + ) + } -PassThru -Force + + $mockDefaultParameters = @{ + ServerObject = $mockServerObject + } + } + + It 'Should return the correct values' { + $result = Get-SqlDscAudit @mockDefaultParameters + + $result | Should -BeOfType 'Microsoft.SqlServer.Management.Smo.Audit' + $result | Should -HaveCount 2 + $result.Name | Should -Contain 'Log1' + $result.Name | Should -Contain 'Log2' + } + } } From d14c0c57e91238a0bf7c95993dd5d2f0f265cb28 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 11 Feb 2023 14:48:00 +0100 Subject: [PATCH 02/13] Fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a874404e..515b38663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -257,7 +257,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 _two properties will always return an empty array._ - `Get-SqlDscAudit` - The parameter `Name` is no longer mandatory. When left out all the current - audits are returned. + audits are returned ([issue #1812](https://github.com/dsccommunity/SqlServerDsc/issues/1812)). ### Fixed From a5d99add3fb594e6745fc5106e862d7964c6b1c6 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 11 Feb 2023 17:07:30 +0100 Subject: [PATCH 03/13] Fix SqlAudit ti handle array from Get-SqlDscAudit --- source/Classes/020.SqlAudit.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/Classes/020.SqlAudit.ps1 b/source/Classes/020.SqlAudit.ps1 index 25b5afd4e..31494e05b 100644 --- a/source/Classes/020.SqlAudit.ps1 +++ b/source/Classes/020.SqlAudit.ps1 @@ -261,7 +261,8 @@ class SqlAudit : SqlResourceBase $serverObject = $this.GetServerObject() $auditObject = $serverObject | - Get-SqlDscAudit -Name $properties.Name -ErrorAction 'SilentlyContinue' + Get-SqlDscAudit -Name $properties.Name -ErrorAction 'SilentlyContinue' | + Select-Object -First 1 if ($auditObject) { @@ -350,7 +351,8 @@ class SqlAudit : SqlResourceBase if ($this.Ensure -eq [Ensure]::Present) { $auditObject = $serverObject | - Get-SqlDscAudit -Name $this.Name -ErrorAction 'Stop' + Get-SqlDscAudit -Name $this.Name -ErrorAction 'Stop' | + Select-Object -First 1 if ($auditObject) { From dec394e9c438c7b7f3842f33ec64f282c21fd24d Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 12 Feb 2023 14:56:26 +0100 Subject: [PATCH 04/13] Fix Remove-SqlDscAudit --- source/Public/Remove-SqlDscAudit.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Public/Remove-SqlDscAudit.ps1 b/source/Public/Remove-SqlDscAudit.ps1 index 56a6d5e0c..dfc2a9147 100644 --- a/source/Public/Remove-SqlDscAudit.ps1 +++ b/source/Public/Remove-SqlDscAudit.ps1 @@ -85,7 +85,8 @@ function Remove-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters + $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | + Select-Object -First 1 } $verboseDescriptionMessage = $script:localizedData.Audit_Remove_ShouldProcessVerboseDescription -f $AuditObject.Name, $AuditObject.Parent.InstanceName From 137f913fd32d681d1a09b69bf3fcf2120a1f5ad5 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 12 Feb 2023 15:01:42 +0100 Subject: [PATCH 05/13] Fix commands --- source/Public/Disable-SqlDscAudit.ps1 | 3 ++- source/Public/Enable-SqlDscAudit.ps1 | 3 ++- source/Public/New-SqlDscAudit.ps1 | 3 ++- source/Public/Set-SqlDscAudit.ps1 | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/Public/Disable-SqlDscAudit.ps1 b/source/Public/Disable-SqlDscAudit.ps1 index dca7e3bfa..79ec71c38 100644 --- a/source/Public/Disable-SqlDscAudit.ps1 +++ b/source/Public/Disable-SqlDscAudit.ps1 @@ -85,7 +85,8 @@ function Disable-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters + $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | + Select-Object -First 1 } $verboseDescriptionMessage = $script:localizedData.Audit_Disable_ShouldProcessVerboseDescription -f $AuditObject.Name, $AuditObject.Parent.InstanceName diff --git a/source/Public/Enable-SqlDscAudit.ps1 b/source/Public/Enable-SqlDscAudit.ps1 index f492d912c..5a403c89d 100644 --- a/source/Public/Enable-SqlDscAudit.ps1 +++ b/source/Public/Enable-SqlDscAudit.ps1 @@ -85,7 +85,8 @@ function Enable-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters + $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | + Select-Object -First 1 } $verboseDescriptionMessage = $script:localizedData.Audit_Enable_ShouldProcessVerboseDescription -f $AuditObject.Name, $AuditObject.Parent.InstanceName diff --git a/source/Public/New-SqlDscAudit.ps1 b/source/Public/New-SqlDscAudit.ps1 index 99bad6a49..856bbcef4 100644 --- a/source/Public/New-SqlDscAudit.ps1 +++ b/source/Public/New-SqlDscAudit.ps1 @@ -214,7 +214,8 @@ function New-SqlDscAudit ErrorAction = 'SilentlyContinue' } - $auditObject = Get-SqlDscAudit @getSqlDscAuditParameters + $auditObject = Get-SqlDscAudit @getSqlDscAuditParameters | + Select-Object -First 1 if ($auditObject) { diff --git a/source/Public/Set-SqlDscAudit.ps1 b/source/Public/Set-SqlDscAudit.ps1 index e783cf920..2f60d8c35 100644 --- a/source/Public/Set-SqlDscAudit.ps1 +++ b/source/Public/Set-SqlDscAudit.ps1 @@ -259,7 +259,8 @@ function Set-SqlDscAudit ErrorAction = 'Stop' } - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters + $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | + Select-Object -First 1 } if ($Refresh.IsPresent) From 102824067ce53e9f57f88e754040669a5b6c3935 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 5 Mar 2023 15:46:16 +0100 Subject: [PATCH 06/13] Try casting --- source/Public/Remove-SqlDscAudit.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/Public/Remove-SqlDscAudit.ps1 b/source/Public/Remove-SqlDscAudit.ps1 index dfc2a9147..366ecd504 100644 --- a/source/Public/Remove-SqlDscAudit.ps1 +++ b/source/Public/Remove-SqlDscAudit.ps1 @@ -85,8 +85,10 @@ function Remove-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | - Select-Object -First 1 + $AuditObject = [Microsoft.SqlServer.Management.Smo.Audit] ( + Get-SqlDscAudit @getSqlDscAuditParameters | + Select-Object -First 1 + ) } $verboseDescriptionMessage = $script:localizedData.Audit_Remove_ShouldProcessVerboseDescription -f $AuditObject.Name, $AuditObject.Parent.InstanceName From 6c984f17ac630d31bc2e65ccb776353765984d4a Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 5 Mar 2023 15:52:44 +0100 Subject: [PATCH 07/13] Fix CHANGELOG --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 515b38663..8d3de7479 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed the regular expression `features?` from the GitVersion configuration. Before, if a fix commit mentioned the word feature but means a SQL Server feature GitVersion would bump minor instead of patch number. +- `Get-SqlDscAudit` + - The parameter `Name` is no longer mandatory. When left out all the current + audits are returned ([issue #1812](https://github.com/dsccommunity/SqlServerDsc/issues/1812)). ### Fixed @@ -255,9 +258,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Get-TargetResource` was updated to always return an array for parameter `TraceFlags`, `TraceFlagsToInclude`, and `TraceFlagsToInclude`. _The last_ _two properties will always return an empty array._ -- `Get-SqlDscAudit` - - The parameter `Name` is no longer mandatory. When left out all the current - audits are returned ([issue #1812](https://github.com/dsccommunity/SqlServerDsc/issues/1812)). ### Fixed From 97488e1868788c67133e601b94f1d306234e1760 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 5 Mar 2023 15:55:47 +0100 Subject: [PATCH 08/13] Fix unit test --- tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 b/tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 index 392e04259..d857b9b86 100644 --- a/tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 +++ b/tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 @@ -53,7 +53,7 @@ Describe 'Get-SqlDscAudit' -Tag 'Public' { It 'Should have the correct parameters in parameter set ' -ForEach @( @{ MockParameterSetName = '__AllParameterSets' - MockExpectedParameters = '[-ServerObject] [-Name] [-Refresh] []' + MockExpectedParameters = '[-ServerObject] [[-Name] ] [-Refresh] []' } ) { $result = (Get-Command -Name 'Get-SqlDscAudit').ParameterSets | From dd231b1b0e4ee7f87f56c5374975682efdd874a6 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 7 Mar 2023 06:55:43 +0100 Subject: [PATCH 09/13] Remove casting --- source/Public/Remove-SqlDscAudit.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/Public/Remove-SqlDscAudit.ps1 b/source/Public/Remove-SqlDscAudit.ps1 index 366ecd504..9a9e0711e 100644 --- a/source/Public/Remove-SqlDscAudit.ps1 +++ b/source/Public/Remove-SqlDscAudit.ps1 @@ -85,10 +85,8 @@ function Remove-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $AuditObject = [Microsoft.SqlServer.Management.Smo.Audit] ( - Get-SqlDscAudit @getSqlDscAuditParameters | + $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | Select-Object -First 1 - ) } $verboseDescriptionMessage = $script:localizedData.Audit_Remove_ShouldProcessVerboseDescription -f $AuditObject.Name, $AuditObject.Parent.InstanceName From edef7a3ef53d7c7bc19bd09704d4a3aacee07d03 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 7 Mar 2023 08:21:35 +0100 Subject: [PATCH 10/13] Fix casting to correct type --- source/Public/Remove-SqlDscAudit.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/Public/Remove-SqlDscAudit.ps1 b/source/Public/Remove-SqlDscAudit.ps1 index 9a9e0711e..e872ae439 100644 --- a/source/Public/Remove-SqlDscAudit.ps1 +++ b/source/Public/Remove-SqlDscAudit.ps1 @@ -85,8 +85,10 @@ function Remove-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | - Select-Object -First 1 + $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters + + # Pick the only object in the array. + $AuditObject = $auditObjectArray | Select-Object -First 1 } $verboseDescriptionMessage = $script:localizedData.Audit_Remove_ShouldProcessVerboseDescription -f $AuditObject.Name, $AuditObject.Parent.InstanceName From 827d7088888918f17ad2e57f8ac18ebacf97a7bd Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 7 Mar 2023 12:01:26 +0100 Subject: [PATCH 11/13] Fix handle array from Get-SqlDscAudit --- source/Classes/020.SqlAudit.ps1 | 16 ++++++++++------ source/Public/Disable-SqlDscAudit.ps1 | 7 +++++-- source/Public/Enable-SqlDscAudit.ps1 | 7 +++++-- source/Public/New-SqlDscAudit.ps1 | 5 ++--- source/Public/Set-SqlDscAudit.ps1 | 8 ++++++-- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/source/Classes/020.SqlAudit.ps1 b/source/Classes/020.SqlAudit.ps1 index 31494e05b..cef0670f1 100644 --- a/source/Classes/020.SqlAudit.ps1 +++ b/source/Classes/020.SqlAudit.ps1 @@ -260,9 +260,11 @@ class SqlAudit : SqlResourceBase $serverObject = $this.GetServerObject() - $auditObject = $serverObject | - Get-SqlDscAudit -Name $properties.Name -ErrorAction 'SilentlyContinue' | - Select-Object -First 1 + $auditObjectArray = $serverObject | + Get-SqlDscAudit -Name $properties.Name -ErrorAction 'SilentlyContinue' + + # Pick the only object in the array. + $auditObject = $auditObjectArray | Select-Object -First 1 if ($auditObject) { @@ -350,9 +352,11 @@ class SqlAudit : SqlResourceBase #> if ($this.Ensure -eq [Ensure]::Present) { - $auditObject = $serverObject | - Get-SqlDscAudit -Name $this.Name -ErrorAction 'Stop' | - Select-Object -First 1 + $auditObjectArray = $serverObject | + Get-SqlDscAudit -Name $this.Name -ErrorAction 'Stop' + + # Pick the only object in the array. + $auditObject = $auditObjectArray | Select-Object -First 1 if ($auditObject) { diff --git a/source/Public/Disable-SqlDscAudit.ps1 b/source/Public/Disable-SqlDscAudit.ps1 index 79ec71c38..e93413df4 100644 --- a/source/Public/Disable-SqlDscAudit.ps1 +++ b/source/Public/Disable-SqlDscAudit.ps1 @@ -85,8 +85,11 @@ function Disable-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | - Select-Object -First 1 + $auditObjectArray = $serverObject | + Get-SqlDscAudit -Name @getSqlDscAuditParameters + + # Pick the only object in the array. + $AuditObject = $auditObjectArray | Select-Object -First 1 } $verboseDescriptionMessage = $script:localizedData.Audit_Disable_ShouldProcessVerboseDescription -f $AuditObject.Name, $AuditObject.Parent.InstanceName diff --git a/source/Public/Enable-SqlDscAudit.ps1 b/source/Public/Enable-SqlDscAudit.ps1 index 5a403c89d..3ce7599cd 100644 --- a/source/Public/Enable-SqlDscAudit.ps1 +++ b/source/Public/Enable-SqlDscAudit.ps1 @@ -85,8 +85,11 @@ function Enable-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | - Select-Object -First 1 + $auditObjectArray = $serverObject | + Get-SqlDscAudit -Name @getSqlDscAuditParameters + + # Pick the only object in the array. + $AuditObject = $auditObjectArray | Select-Object -First 1 } $verboseDescriptionMessage = $script:localizedData.Audit_Enable_ShouldProcessVerboseDescription -f $AuditObject.Name, $AuditObject.Parent.InstanceName diff --git a/source/Public/New-SqlDscAudit.ps1 b/source/Public/New-SqlDscAudit.ps1 index 856bbcef4..5706491ab 100644 --- a/source/Public/New-SqlDscAudit.ps1 +++ b/source/Public/New-SqlDscAudit.ps1 @@ -214,10 +214,9 @@ function New-SqlDscAudit ErrorAction = 'SilentlyContinue' } - $auditObject = Get-SqlDscAudit @getSqlDscAuditParameters | - Select-Object -First 1 + $auditObject = Get-SqlDscAudit @getSqlDscAuditParameters - if ($auditObject) + if ($auditObject.Count -gt 0) { $auditAlreadyPresentMessage = $script:localizedData.Audit_AlreadyPresent -f $Name diff --git a/source/Public/Set-SqlDscAudit.ps1 b/source/Public/Set-SqlDscAudit.ps1 index 2f60d8c35..ede1846ce 100644 --- a/source/Public/Set-SqlDscAudit.ps1 +++ b/source/Public/Set-SqlDscAudit.ps1 @@ -259,8 +259,12 @@ function Set-SqlDscAudit ErrorAction = 'Stop' } - $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters | - Select-Object -First 1 + # If this command does not find the audit it will throw an exception. + $auditObjectArray = $serverObject | + Get-SqlDscAudit -Name @getSqlDscAuditParameters + + # Pick the only object in the array. + $AuditObject = $auditObjectArray | Select-Object -First 1 } if ($Refresh.IsPresent) From 90328866b9cdf5efbdd2054695b30c0766703014 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 7 Mar 2023 13:03:27 +0100 Subject: [PATCH 12/13] Fix bugs --- source/Public/Disable-SqlDscAudit.ps1 | 2 +- source/Public/Enable-SqlDscAudit.ps1 | 2 +- source/Public/Set-SqlDscAudit.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Public/Disable-SqlDscAudit.ps1 b/source/Public/Disable-SqlDscAudit.ps1 index e93413df4..0cae4067e 100644 --- a/source/Public/Disable-SqlDscAudit.ps1 +++ b/source/Public/Disable-SqlDscAudit.ps1 @@ -86,7 +86,7 @@ function Disable-SqlDscAudit # If this command does not find the audit it will throw an exception. $auditObjectArray = $serverObject | - Get-SqlDscAudit -Name @getSqlDscAuditParameters + Get-SqlDscAudit @getSqlDscAuditParameters # Pick the only object in the array. $AuditObject = $auditObjectArray | Select-Object -First 1 diff --git a/source/Public/Enable-SqlDscAudit.ps1 b/source/Public/Enable-SqlDscAudit.ps1 index 3ce7599cd..d1ef8ed2c 100644 --- a/source/Public/Enable-SqlDscAudit.ps1 +++ b/source/Public/Enable-SqlDscAudit.ps1 @@ -86,7 +86,7 @@ function Enable-SqlDscAudit # If this command does not find the audit it will throw an exception. $auditObjectArray = $serverObject | - Get-SqlDscAudit -Name @getSqlDscAuditParameters + Get-SqlDscAudit @getSqlDscAuditParameters # Pick the only object in the array. $AuditObject = $auditObjectArray | Select-Object -First 1 diff --git a/source/Public/Set-SqlDscAudit.ps1 b/source/Public/Set-SqlDscAudit.ps1 index ede1846ce..762010a47 100644 --- a/source/Public/Set-SqlDscAudit.ps1 +++ b/source/Public/Set-SqlDscAudit.ps1 @@ -261,7 +261,7 @@ function Set-SqlDscAudit # If this command does not find the audit it will throw an exception. $auditObjectArray = $serverObject | - Get-SqlDscAudit -Name @getSqlDscAuditParameters + Get-SqlDscAudit @getSqlDscAuditParameters # Pick the only object in the array. $AuditObject = $auditObjectArray | Select-Object -First 1 From 5010c286affa5c390180acb7e58dbde9a5a4176b Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 7 Mar 2023 13:53:14 +0100 Subject: [PATCH 13/13] Fix bugs again --- source/Public/Disable-SqlDscAudit.ps1 | 3 +-- source/Public/Enable-SqlDscAudit.ps1 | 3 +-- source/Public/Set-SqlDscAudit.ps1 | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/source/Public/Disable-SqlDscAudit.ps1 b/source/Public/Disable-SqlDscAudit.ps1 index 0cae4067e..c6ff1423f 100644 --- a/source/Public/Disable-SqlDscAudit.ps1 +++ b/source/Public/Disable-SqlDscAudit.ps1 @@ -85,8 +85,7 @@ function Disable-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $auditObjectArray = $serverObject | - Get-SqlDscAudit @getSqlDscAuditParameters + $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters # Pick the only object in the array. $AuditObject = $auditObjectArray | Select-Object -First 1 diff --git a/source/Public/Enable-SqlDscAudit.ps1 b/source/Public/Enable-SqlDscAudit.ps1 index d1ef8ed2c..e2682faf2 100644 --- a/source/Public/Enable-SqlDscAudit.ps1 +++ b/source/Public/Enable-SqlDscAudit.ps1 @@ -85,8 +85,7 @@ function Enable-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $auditObjectArray = $serverObject | - Get-SqlDscAudit @getSqlDscAuditParameters + $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters # Pick the only object in the array. $AuditObject = $auditObjectArray | Select-Object -First 1 diff --git a/source/Public/Set-SqlDscAudit.ps1 b/source/Public/Set-SqlDscAudit.ps1 index 762010a47..7083d7afd 100644 --- a/source/Public/Set-SqlDscAudit.ps1 +++ b/source/Public/Set-SqlDscAudit.ps1 @@ -260,8 +260,7 @@ function Set-SqlDscAudit } # If this command does not find the audit it will throw an exception. - $auditObjectArray = $serverObject | - Get-SqlDscAudit @getSqlDscAuditParameters + $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters # Pick the only object in the array. $AuditObject = $auditObjectArray | Select-Object -First 1