Skip to content

Commit

Permalink
Merge pull request #5724 from NikCharlebois/Trap-Errors
Browse files Browse the repository at this point in the history
AADServicePrincipal - Fix Null Values
  • Loading branch information
NikCharlebois authored Feb 4, 2025
2 parents c879202 + 584d620 commit 1e9d98c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

* AADConditionalAccessPolicy
* Changed the InsiderRiskTypes property to a string array.
* AADServicePrincipal
* Fixes comparison of assigned roles for null values.
FIXES [#5717](https://github.com/microsoft/Microsoft365DSC/issues/5717)
* MISC
* Changed the CIMInstance logic of various resources to us common logic.
* Added support for specifying a proxy in Update-M365DSCModule.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,15 @@ function Set-TargetResource
[Array]$currentPrincipals = $currentAADServicePrincipal.AppRoleAssignedTo.Identity
[Array]$desiredPrincipals = $AppRoleAssignedTo.Identity

if ($null -eq $currentPrincipals)
{
$currentPrincipals = @()
}
if ($null -eq $desiredPrincipals)
{
$desiredPrincipals = @()
}

[Array]$differences = Compare-Object -ReferenceObject $currentPrincipals -DifferenceObject $desiredPrincipals
[Array]$membersToAdd = $differences | Where-Object -FilterScript { $_.SideIndicator -eq '=>' }
[Array]$membersToRemove = $differences | Where-Object -FilterScript { $_.SideIndicator -eq '<=' }
Expand Down

0 comments on commit 1e9d98c

Please sign in to comment.