I need the accountenabled property to further the script, but for Get-MgUser
.
I need to modify the current script that have Msol or AzureAD cmdlets to MSGraph, but I can’t find anything so i don’t throw out the script and create a new one.
Get-AzureADUser -Filter "UserPrincipalName eq '$UserPrincipalName'" | select ObjectId, AccountEnabled
2
Answers
To retrieve the AccountEnabled property using the Get-MgUser cmdlet, you can try the following PowerShell script
In order to get he users with account enabled in microsoft graph check the following:
Install-Module Microsoft.Graph -AllowClobber -Force
Connect-MgGraph -Scopes 'User.Read.All'
Get-MgUser -Filter 'accountEnabled eq true' -All
Result:
It doesn’t have the particular property account enabled but can be filtered
x
Reference: Get-MgUser (Microsoft.Graph.Users) | Microsoft Learn
In azure ad commandlets we get those properties :
Get-AzureADUser | select ObjectId, AccountEnabled