LastSignInDateTime = if($User.signInActivity. $Result += New-Object PSObject -property = $User.displayName $Response = Invoke-RestMethod -Method GET -Uri $ApiUrl -ContentType "application/json" -Headers $headers $Result = ($ApiUrl -ne $Null) #Perform pagination if next page link (odata.nextlink) returned. $ApiUrl = "`$select=displayName,userPrincipalName,signInActivity,userType,assignedLicenses" You can refer to the following post to know more about App Registration and Enterprise Application in Azure AD. We can also use this app without registering custom app in your tenant. The Microsoft Graph PowerShell SDK uses this app for Graph API resource access. #This request get users list with signInActivity. The Microsoft Graph PowerShell app is the pre-registered multi-tenant Azure AD app. #Form request headers with the acquired $AccessToken You can close the PowerShell and re-open it once you installed the module. Run the following command in PowerShell to install this module. We can use the MSAL.PS library to acquire access tokens with Delegated permissions. List Licensed users/Guest users with last login date.Export Last login date for all Microsoft 365 Users.Until now, the Graph API powered AzureAD PowerShell V2 (AzureAD /AzureADPreview) module also does not expose this property. We can get the signInActivity property only by querying the Graph API directly. Before Microsoft Graph supports this property, we need to either get the mailbox last logon time using the Get-MailboxStatistics cmdlet or we need to crawl the Azure AD sign-in logs or the Unified audit logs in the Security and Compliance Center. Up until now, this is the only possible way to get the last sign-in date for users.
0 Comments
Leave a Reply. |