diff --git a/CHANGELOG.md b/CHANGELOG.md index eaa821df72..1fe2b370d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change log for Microsoft365DSC +# UNRELEASED + +* AADAuthenticationMethodPolicyAuthenticator + * Fixes an issue with the Get method when an assigned group + was deleted. + # 1.23.1011.1 * AADRoleEligibilityScheduleRequest diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.psm1 index f1375183c9..ddb27d4f21 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.psm1 @@ -247,8 +247,12 @@ function Get-TargetResource $myExcludeTargets = @{} if ($currentExcludeTargets.id -ne 'all_users') { - $myExcludeTargetsDisplayName = Get-MgGroup -GroupId $currentExcludeTargets.id - $myExcludeTargets.Add('Id', $myExcludeTargetsDisplayName.DisplayName) + $myExcludeTargetsDisplayName = Get-MgGroup -GroupId $currentExcludeTargets.id -ErrorAction SilentlyContinue + + if ($null -ne $myIncludeTargetsDisplayName) + { + $myExcludeTargets.Add('Id', $myExcludeTargetsDisplayName.DisplayName) + } } else { @@ -271,8 +275,11 @@ function Get-TargetResource $myIncludeTargets = @{} if ($currentIncludeTargets.id -ne 'all_users') { - $myIncludeTargetsDisplayName = Get-MgGroup -GroupId $currentIncludeTargets.id - $myIncludeTargets.Add('Id', $myIncludeTargetsDisplayName.DisplayName) + $myIncludeTargetsDisplayName = Get-MgGroup -GroupId $currentIncludeTargets.id -ErrorAction SilentlyContinue + if ($null -ne $myIncludeTargetsDisplayName) + { + $myIncludeTargets.Add('Id', $myIncludeTargetsDisplayName.DisplayName) + } } else {