Forum Discussion
JakobRohde
Sep 22, 2017Iron Contributor
List all users' last login date
Is it possible, using PowerShell, to list all AAD users' last login date (no matter how they logged in)? I have found a couple of scripts that check the last mailbox login, but that is not what we ne...
Deleted
Jan 05, 2022Hi NicolasHon, does on have to create an app still? I see in the docs that one can authenticate directly in powershell with an admin account by using graph SDK (https://docs.microsoft.com/en-us/graph/powershell/get-started) Or have I misunderstood?
Could something like this work with only direct commands in powershell?
Install-Module Microsoft.Graph
Connect-MgGraph -Scope "User.Read.All"
Select-MgProfile -Name "beta"
Get-MgUser -Filter "signInActivity/lastSignInDateTime le 2021-09-30T00:00:00Z$select=id,displayName,userType"
$Result | Export-CSV "C:\Temp\LastLoginDateReport.CSV" -NoTypeInformation -Encoding UTF8
Could something like this work with only direct commands in powershell?
Install-Module Microsoft.Graph
Connect-MgGraph -Scope "User.Read.All"
Select-MgProfile -Name "beta"
Get-MgUser -Filter "signInActivity/lastSignInDateTime le 2021-09-30T00:00:00Z$select=id,displayName,userType"
$Result | Export-CSV "C:\Temp\LastLoginDateReport.CSV" -NoTypeInformation -Encoding UTF8
NicolasHon
Jan 06, 2022Brass Contributor
Hi Niklask, yes you could also achieve that using this way. The thing is that you need to have an admin role to approve Microsoft Graph module when running it from PowerShell. It is less practical as I don't have a permanent admin so I need to go in PIM, activate my admin role, and then run the script. With the app this is not the case as I don't use Graph commands in PowerShell and just do Graph API's calls. The app allow you also to schedule this script in a scheduled task or to access it from a Power Automate Flow to do periodic report.
- mdiloretoSep 12, 2022Copper Contributor
Hello! NicolasHon, how are you? Hope fine.
I extend you and anyone who knows the following question:
I'm getting some users with the LastSignInDateTime empty or with the following date (i reviewed the raw csv, and is not a excel format issue) 1/1/0001 21:00:00
I assume that the empty date means that they never log in to 365 but dont know if the date is the same.
Do you know who this means?
thanks in advance!!
- NicolasHonFeb 17, 2023Brass ContributorYes empty mean never logged-in.
- NicolasHonOct 26, 2022Brass ContributorHi mdiloreto,
I'm fine thanks and hope the same for you.
Sorry for the late answer.
Yes, that is correct. An empty value or inconsistent mean that the user has never been signed-up against Azure AD.
Best Regard