Hello @Roger Roger
Thank you for being patient while I was working on a script to fetch user details from CSV and print the Last Sign-In details for them. I would like to confirm that as of today this is only possible using Microsoft Graph PowerShell Module.
- You need to install Microsoft Graph PowerShell Module using command "Install-Module Microsoft.Graph -Scope CurrentUser". For more information you can refer following documentation: Install the Microsoft Graph PowerShell SDK
- You would need to generate CSV with list of users in following format:
- Once Graph Module is installed and CSV is generated you should be able to execute following script.
Connect-MgGraph -Scopes 'User.Read.All' $csv = Import-Csv -Path "Enter Input CSV file" foreach ($Id in $csv) { $user = Get-MgUser -UserId $Id.ObjectId -Property 'SignInActivity' If ($User.SignInActivity.LastSignInDateTime -eq $null) { Write-host "User "$Id.UserPrincipalName" has never signed in" -ForegroundColor Red } else { Write-Host "Last SignIn Date for user "$Id.UserPrincipalName" is "$user.SignInActivity.LastSignInDateTime"" } }
- Output of the Script would be similar to screenshot below:
I hope this helps you achieve the results you are looking for.
----------
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.