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

AADUser: Ensure: Absent logic seems wrong #4265

Closed
bartvermeersch opened this issue Jan 30, 2024 · 2 comments · Fixed by #4324
Closed

AADUser: Ensure: Absent logic seems wrong #4265

bartvermeersch opened this issue Jan 30, 2024 · 2 comments · Fixed by #4324
Assignees
Labels
Bug Something isn't working Entra ID

Comments

@bartvermeersch
Copy link
Contributor

AAD Users with Ensure set to Absent are removed and recreated every next run after removal.

The logic is correct when the resource exists, but if it doesn't it will just create it although Ensure is set to Absent

if ($user.Ensure -eq 'Present' -and $Ensure -eq 'Absent')

A condition if ($Ensure -eq 'Present') is missing on line 421

@andikrueger andikrueger added Bug Something isn't working Entra ID labels Feb 1, 2024
@William-Francillette
Copy link
Contributor

Tested on my tenant and working ok - Could you check your event viewer > application and service logs > M365DSC if there is any error?

@andikrueger
Copy link
Collaborator

andikrueger commented Feb 14, 2024

@William-Francillette If is read the code correctly, this really a bug.

configuration should look like this and there should not be a user with the UPN John.Smith

AADUser 'ConfigureJohnSMith'
        {
            UserPrincipalName  = "John.Smith@$Domain"
            DisplayName        = "John J. Smith"
            Ensure             = "Absent"
            Credential         = $Credscredential
        }
}

In this case, the Get-Method will return Absent and therefor we will directly jump into the else block. This will result in a new user bein created, even if it should not be created.

Needs to be an

elseif( $Ensure -eq 'Present") 

then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Entra ID
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants