Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AADRoleAssignmentScheduleRequest incorrectly thinks if found existing Principal found #5801

Closed
mpoulson opened this issue Feb 18, 2025 · 0 comments · Fixed by #5802 or #5816
Closed

Comments

@mpoulson
Copy link
Contributor

Description of the issue

Code below assumes the principal was found with one of the 3 attempts. However, there needs to be a check if $PrincipalValue is still null.

Write-Verbose -Message 'Getting Role Eligibility by PrincipalId and RoleDefinitionId'
$PrincipalValue = $null
if ($PrincipalType -eq 'User')
{
Write-Verbose -Message "Retrieving Principal by UserPrincipalName {$Principal}"
$PrincipalInstance = Get-MgUser -Filter "UserPrincipalName eq '$Principal'" -ErrorAction SilentlyContinue
$PrincipalValue = $PrincipalInstance.UserPrincipalName
}
elseif ($null -eq $PrincipalIdValue -and $PrincipalType -eq 'Group')
{
Write-Verbose -Message "Retrieving Principal by DisplayName {$Principal}"
$PrincipalInstance = Get-MgGroup -Filter "DisplayName eq '$Principal'" -ErrorAction SilentlyContinue
$PrincipalValue = $PrincipalInstance.DisplayName
}
else
{
Write-Verbose -Message "Retrieving Principal by DisplayName {$Principal}"
$PrincipalInstance = Get-MgServicePrincipal -Filter "DisplayName eq '$Principal'" -ErrorAction SilentlyContinue
$PrincipalValue = $PrincipalInstance.DisplayName
}

    Write-Verbose -Message 'Found Principal'

Microsoft 365 DSC Version

DEV

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

Verbose logs showing the problem

Environment Information + PowerShell Version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant