Skip to content

Commit

Permalink
Fix Test-TargetResource
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmestre committed Oct 24, 2024
1 parent 39a48c0 commit c93afb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* Fixed missing permissions in settings.json
* EXOMailboxAuditBypassAssociation
* Initial release.
* EXOTenantAllowBlockListItems
* Fixed `Test-TargetResource` to correctly mark when this resource is removed
* IntuneDerivedCredential
* Fixed export and deployment when `NotificationType` had more than one option
selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,18 +378,21 @@ function Test-TargetResource

$CurrentValues = Get-TargetResource @PSBoundParameters
$ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone()
$ValuesToCheck.Remove('Entries') | Out-Null
if ($null -ne $ValuesToCheck.ExpirationDate -and $ValuesToCheck.ExpirationDate.Kind -eq 'Local')
{
$ValuesToCheck.ExpirationDate = $ValuesToCheck.ExpirationDate.ToUniversalTime().ToString()
}

if ($CurrentValues.Ensure -eq 'Absent')
if ($CurrentValues.Ensure -ne $Ensure)
{
Write-Verbose -Message "Test-TargetResource returned $false"
return $false
}

if ($null -ne $ValuesToCheck.ExpirationDate -and $ValuesToCheck.ExpirationDate.Kind -eq 'Local')
{
$ValuesToCheck.ExpirationDate = $ValuesToCheck.ExpirationDate.ToUniversalTime().ToString()
}

$ValuesToCheck = Remove-M365DSCAuthenticationParameter -BoundParameters $ValuesToCheck
$ValuesToCheck.Remove('Entries') | Out-Null

Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)"

Expand Down

0 comments on commit c93afb8

Please sign in to comment.