I'm trying to create a user report out of Azure AD. I need The report needs to have the username, last login and creation date. The GUI only goes back 30 days
I've tried get-mguser -all but it doesnt have all the properties like I would see if I were using get-aduser. Same thing holds true for get-azureaduser -all $true. Any help out there?
CodePudding user response:
You need to use beta
version of Graph API because information about last signed-in date is available only in beta
. The properties you need are userPrincipalName
, createdDateTime
and signInActivity
.
# switch to using beta version
Select-MgProfile -Name "beta"
Import-Module Microsoft.Graph.Users
Get-MgUser -Property "userPrincipalName,createdDateTime,signInActivity"
#second option
Get-MgUser | Select "userPrincipalName,createdDateTime,signInActivity"
Documentation: