Skip to content

Commit

Permalink
Merge pull request #5651 from ricmestre/fix5648
Browse files Browse the repository at this point in the history
M365DSCUtil: Test-M365DSCParameterState: Replace the line endings before making the comparison
  • Loading branch information
ykuijs authored Jan 21, 2025
2 parents 919cac7 + 1263c89 commit a97ee35
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
34 changes: 27 additions & 7 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a97ee35

Please sign in to comment.