From 5ed7542c2b330f0635aeb5f81632e997981301a1 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Thu, 27 Jul 2023 15:18:39 -0400 Subject: [PATCH] Fixes #3498 --- CHANGELOG.md | 3 +++ .../MSFT_SCComplianceSearchAction.psm1 | 24 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f3c27a1d1..dfcc929045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ FIXES [#3518](https://github.com/microsoft/Microsoft365DSC/issues/3518) * O365OrgSettings * Added error handling for the Viva settings to handle task cancellation errors. +* SCComplianceSearchAction + * Adds support for the Preview action type. + FIXES [#3498](https://github.com/microsoft/Microsoft365DSC/issues/3498) * MISC * M365DscReverse: Fix exporting when $Filter var exists locally FIXES [#3515](https://github.com/microsoft/Microsoft365DSC/issues/3515) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_SCComplianceSearchAction/MSFT_SCComplianceSearchAction.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_SCComplianceSearchAction/MSFT_SCComplianceSearchAction.psm1 index 3481b91034..1573313c8b 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_SCComplianceSearchAction/MSFT_SCComplianceSearchAction.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_SCComplianceSearchAction/MSFT_SCComplianceSearchAction.psm1 @@ -121,7 +121,7 @@ function Get-TargetResource $IncludeSP = Get-ResultProperty -ResultString $currentAction.Results -PropertyName 'Include SharePoint versions' $ScopeValue = Get-ResultProperty -ResultString $currentAction.Results -PropertyName 'Scope' - $ActionName = 'Export' + $ActionName = $Action if ('RetentionReports' -eq $Scenario) { $ActionName = 'Retention' @@ -143,6 +143,10 @@ function Get-TargetResource CertificatePassword = $CertificatePassword Ensure = 'Present' } + if ($ActionName -eq 'Preview') + { + $result.Remove('EnableDedupe') | Out-Null + } } else { @@ -317,10 +321,17 @@ function Set-TargetResource 'Purge' { $CreationParams.Add('Purge', $true) - $CreationParams.Remove('ActionScope') - $CreationParams.Remove('Scope') + $CreationParams.Remove('ActionScope') | Out-Null + $CreationParams.Remove('Scope') | Out-Null $CreationParams.Add('Confirm', $false) } + 'Preview' + { + $CreationParams.Add('Preview', $true) + $CreationParams.Remove("Scope") | Out-Null + $CreationParams.Add('Confirm', $false) + $CreationParams.Remove('EnableDedupe') | Out-Null + } } $CreationParams.Remove('Action') @@ -687,7 +698,6 @@ function Get-CurrentAction [Parameter(Mandatory = $true)] [System.String] - [ValidateSet('Export', 'Purge', 'Retention')] $Action ) # For the sake of retrieving the current action, search by Action = Export; @@ -719,7 +729,7 @@ function Get-CurrentAction $currentAction = Get-ComplianceSearchAction | Where-Object { $_.SearchName -eq $SearchName -and $_.Action -eq $Action } } - if ('Purge' -ne $Action -and $null -ne $currentAction) + if ('Purge' -ne $Action -and $null -ne $currentAction -and -not [System.String]::IsNullOrEmpty($Scenario)) { $currentAction = $currentAction | Where-Object { $_.Results -like "*Scenario: $($Scenario)*" } } @@ -727,6 +737,10 @@ function Get-CurrentAction { $currentAction = $currentAction | Where-Object { $_.Action -eq 'Purge' } } + elseif ('Preview' -eq $Action) + { + $currentAction = $currentAction | Where-Object { $_.Action -eq 'Preview' } + } return $currentAction }