Forum Discussion

coxygt's avatar
coxygt
Brass Contributor
Oct 12, 2022
Solved

Last Login dates for all Guests using PowerShell

So I need to be able to report on all guest accounts on my companies tenant, to see the last time they logged on.  AzureADSignin Logs are no good as they only cover last 30 days, I know somewhere within Azure, I have found one guest account where the last login was during 2021, but I need to capture this for all guest accounts?

Is this even possible?


Thanks in advance for any help.

3 Replies

  • Thiraviam5316's avatar
    Thiraviam5316
    Brass Contributor

    coxygt You can easily find the last logon details of a guest users using a single cmdlet 'Get-MgUser'.
     

    Get-MgUser -All -Filter "UserType eq 'Guest'" -Property SignInActivity | Select-Object userprincipalname -ExpandProperty SignInActivity | Format-List

     For additional information about guest users management, check: https://m365scripts.com/microsoft365/a-quick-approach-to-manage-guest-users-in-microsoft-365-using-powershell/ 

    • coxygt's avatar
      coxygt
      Brass Contributor
      Thanks Vasil,
      Have downloaded, just need to check the permissions etc.

Resources