Sep 22 2017
01:51 AM
- last edited on
Jan 14 2022
05:29 PM
by
TechCommunityAP
Sep 22 2017
01:51 AM
- last edited on
Jan 14 2022
05:29 PM
by
TechCommunityAP
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 need, because we also want to list unlicensed users.
Sep 23 2017 07:51 AM
No. Use the report in the O365 admin center -> Reports -> Usage -> Active users.
Sep 24 2017 10:10 PM
Nov 23 2017 09:57 AM
I think this is what you need.
The above functionality is available in AdminDroid Office 365 Reporter.
May 10 2018 06:38 AM
This might give you what you're after...
May 10 2018 08:02 AM
The provided script gives you the last login information of users who have Exchange Online license whereas the requirement is to display "last logon time" of unlicensed users as well.
May 10 2018 08:31 AM
Hi Robert,
I tested the script it also provides the logon times for "Unlicensed Users" as well and exports them to a .CSV.
May 10 2018 08:54 AM
Once you've logged in and authenticated against your Office 365 tenant, you can then use the below commands.
# Connects you to Windows Azure Active Directory
Connect-MsolService
# Gets Unlicenced users and lists the "DisplayName, LastLogonTime and LastLogoffTime"
Get-MsolUser -UnlicensedUsersOnly | Foreach {Get-MailboxStatistics $_.UserPrincipalName | Select DisplayName, LastLogonTime, LastLogoffTime}
Jun 13 2018 01:26 PM
What about users who don't have mailboxes? I have a number of users for whom we have disabled the Exchange Online license. How can I get their logon statistics?
Jun 13 2018 02:24 PM
Just a warning that using the Get-MailboxStatistics cmdlet to get this information is highly unreliable (see @Tony Redmond's great blog on that here: https://www.petri.com/get-mailboxstatistics-cmdlet-wrong). The Office 365 usage reports is really the better answer here.
Jun 16 2018 08:19 PM
It's not only unreliable, it's impossible. Get-MailboxStatistics only returns statistics for mailboxes, but I specifically need logon statistics for people who do not have mailboxes.
Apr 21 2020 05:15 AM
Apr 21 2020 07:31 AM
Apr 21 2020 10:54 AM
Hey @Robert Luck,
Is this a secure tool? Since you are giving access to your whole organization.
I cannot seem to find the type of report I want in Azure reporting so I am thinking if investing is tool such as this one, is a smart investment..
Thanks!
Apr 27 2020 01:43 AM
@ManjaMso1 Yes, please check the blog to know more about the security implementation. Also, if you have any other queries, feel free to reach out to us.
May 01 2020 03:04 PM
This doesnt seem to work for me. When i try using it i either get this error:
"error": {
"code": "Authentication_RequestFromUnsupportedUserRole",
"message": "User is not in the allowed roles",
"innerError": {
"request-id": "0119ef60-c3bb-40c1-8f58-7f201bf6d8da",
"date": "2020-05-01T21:46:51"
}
I checked i am global admin and part of the security reader groups.
Or the command does work, but the results are returned with no logon dates. Have you had any luck getting to work ? recently?
Thanks,
Robert
May 01 2020 03:57 PM
One other Note:
When i run this URL: https://graph.microsoft.com/v1.0/users?$select=displayName,userPrincipalName,signInActivity
From here:
https://docs.microsoft.com/en-us/graph/api/user-list?view=graph-rest-beta&tabs=http#code-try-21
After First selecting "Try it" next to the code.
Then selecting V 1.0
It shows me users that are not in my tenant, that have never been in my tenant, and a tenant name that has never been mine. Just an FYI on that.
Thanks,
Robert
May 01 2020 11:43 PM
May 02 2020 06:49 AM
May 02 2020 06:57 AM
Ok that worked! Thanks for your assistance. Now how can i see all the users in the tenant? I am testing with my own tenant which only has about 20 users, so can i assume that if i run the above query on a larger tenant that it will just return all users?
Also, How long does the logging go back for ? is the standard Windows Azure 90 Days? Can i access Microsoft Graph using Excel?
Thanks,
Robert