diff --git a/CHANGELOG.md b/CHANGELOG.md index e11ff6a006..933fb4e71e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change log for Microsoft365DSC +# UNRELEASED + +* SCProtectionAlert + * Prevents extracting system rules. + FIXES [#3224](https://github.com/microsoft/Microsoft365DSC/issues/3224) + # 1.23.614.1 * AADApplication diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_SCLabelPolicy/MSFT_SCLabelPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_SCLabelPolicy/MSFT_SCLabelPolicy.psm1 index 56d428c0cb..d994b4f7f9 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_SCLabelPolicy/MSFT_SCLabelPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_SCLabelPolicy/MSFT_SCLabelPolicy.psm1 @@ -985,7 +985,14 @@ function Convert-CIMToAdvancedSettings if ($obj.Value -ne 'None') { $label = Get-Label | Where-Object -FilterScript { $_.DisplayName -eq $obj.Value } - $settingsValues = $label.ImmutableId.ToString() + if ($null -eq $label) + { + Write-Error -Message "Label {$($obj.value)} doesn't exist. Please define the Sensitivy label first before trying to assign it to a policy." + } + else + { + $settingsValues = $label.ImmutableId.ToString() + } } else { diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_SCProtectionAlert/MSFT_SCProtectionAlert.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_SCProtectionAlert/MSFT_SCProtectionAlert.psm1 index 583d151ea1..c2728a4451 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_SCProtectionAlert/MSFT_SCProtectionAlert.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_SCProtectionAlert/MSFT_SCProtectionAlert.psm1 @@ -640,7 +640,7 @@ function Export-TargetResource try { - [array]$Alerts = Get-ProtectionAlert -ErrorAction Stop + [array]$Alerts = Get-ProtectionAlert -ErrorAction Stop | Where-Object -FilterScript {-not $_.IsSystemRule} $totalAlerts = $Alerts.Length if ($null -eq $totalAlerts)