diff --git a/CHANGELOG.md b/CHANGELOG.md index 25020a24d1..ed09f9a54d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ # Change log for Microsoft365DSC # UNRELEASED + +* M365DSCUtil + * In `Test-M365DSCParameterState` try to replace the line endings before + making the comparison otherwise it may fail as it did for a few resources + FIXES [#5648](https://github.com/microsoft/Microsoft365DSC/issues/5648) * IntuneAppProtectionPolicyiOS - * Fixes [#5589] https://github.com/microsoft/Microsoft365DSC/issues/5589 + * FIXES [#5589](https://github.com/microsoft/Microsoft365DSC/issues/5589) * AADConditionalAccessPolicy * Fixed DisableResilienceDefaults result diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 76e01728c3..f59acc102a 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -839,16 +839,36 @@ function Test-M365DSCParameterState { 'String' { - if ([string]::IsNullOrEmpty($CurrentValues.$fieldName) ` - -and [string]::IsNullOrEmpty($DesiredValues.$fieldName)) + if (-not [string]::IsNullOrEmpty($CurrentValues.$fieldName)) + { + try + { + $CurrentValues.$fieldName = $CurrentValues.$fieldName.Replace("`r`n", "`n") + } + catch + { + } + } + if (-not [string]::IsNullOrEmpty($DesiredValues.$fieldName)) + { + try + { + $DesiredValues.$fieldName = $DesiredValues.$fieldName.Replace("`r`n", "`n") + } + catch + { + } + } + + if ([string]::IsNullOrEmpty($CurrentValues.$fieldName) -and + [string]::IsNullOrEmpty($DesiredValues.$fieldName)) { } # Align line breaks - elseif (-not [string]::IsNullOrEmpty($CurrentValues.$fieldName) ` - -and -not [string]::IsNullOrEmpty($DesiredValues.$fieldName) ` - -and [string]::Equals($CurrentValues.$fieldName.Replace("`r`n", "`n"), ` - $DesiredValues.$fieldName.Replace("`r`n", "`n"), ` - [System.StringComparison]::Ordinal)) + elseif (-not [string]::IsNullOrEmpty($CurrentValues.$fieldName) -and + -not [string]::IsNullOrEmpty($DesiredValues.$fieldName) -and + [string]::Equals($CurrentValues.$fieldName, $DesiredValues.$fieldName, + [System.StringComparison]::Ordinal)) { } else