Skip to content

Commit

Permalink
Merge pull request #2744 from NikCharlebois/FIX#2728
Browse files Browse the repository at this point in the history
FIXES #2728
  • Loading branch information
NikCharlebois authored Jan 4, 2023
2 parents b853391 + 321380b commit 5df50a1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
* SCRetentionCompliancePolicy
* Forces changes to existing policies to be applied.
FIXES [#2719](https://github.com/microsoft/Microsoft365DSC/issues/2719)
* Handles wait when the associated policy has pending changes.
FIXES [#2728](https://github.com/microsoft/Microsoft365DSC/issues/2728)
* SCRetentionComplianceRule
* Handles wait when the associated policy has pending changes.
FIXES [#2728](https://github.com/microsoft/Microsoft365DSC/issues/2728)
* TeamsEmergencyCallingPolicy
* Fixes issue where CertificateThumbprint wasn't working because Credential was set to mandatory by the Test-TargetResource function.
FIXES [#2710](https://github.com/microsoft/Microsoft365DSC/issues/2710)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,29 @@ function Set-TargetResource
}

Write-Verbose "Updating Policy with values: $(Convert-M365DscHashtableToString -Hashtable $CreationParams)"
Set-RetentionCompliancePolicy @CreationParams -Force
$success = $false
$retries = 1
while (!$success -and $retries -le 10)
{
try
{
Set-RetentionCompliancePolicy @CreationParams -Force -ErrorAction Stop
$success = $true
}
catch
{
if ($_.Exception.Message -like "*are being deployed. Once deployed, additional actions can be performed*")
{
Write-Verbose -Message "The policy has pending changes being deployed. Waiting 30 seconds for a maximum of 300 seconds (5 minutes). Total time waited so far {$($retries * 30) seconds}"
Start-Sleep -Seconds 30
}
else
{
$success = $true
}
}
$retries++
}
}
elseif (('Absent' -eq $Ensure) -and ('Present' -eq $CurrentPolicy.Ensure))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,30 @@ function Set-TargetResource
}

Write-Verbose -Message "Updating RetentionComplianceRule with values:`r`n$(Convert-M365DscHashtableToString -Hashtable $CreationParams)"
Set-RetentionComplianceRule @CreationParams

$success = $false
$retries = 1
while (!$success -and $retries -le 10)
{
try
{
Set-RetentionComplianceRule @CreationParams -ErrorAction Stop
$success = $true
}
catch
{
if ($_.Exception.Message -like "*are being deployed. Once deployed, additional actions can be performed*")
{
Write-Verbose -Message "The associated policy has pending changes being deployed. Waiting 30 seconds for a maximum of 300 seconds (5 minutes). Total time waited so far {$($retries * 30) seconds}"
Start-Sleep -Seconds 30
}
else
{
$success = $true
}
}
$retries++
}
}
elseif (('Absent' -eq $Ensure) -and ('Present' -eq $CurrentPolicy.Ensure))
{
Expand Down

0 comments on commit 5df50a1

Please sign in to comment.