Get Last login details

Get Last login details from list of Email ID

Import-csv .\himanshu.csv |foreach {Get-MailboxStatistics -identity $_.emailid | Select-object DisplayName,LastLogonTime} | Export-CSV c:\lastlogonstatics.csv


For All Mailboxes -

Get-Mailbox -RecipientTypeDetails usermailbox -ResultSize unlimited | foreach {Get-MailboxStatistics -identity $_.UserPrincipalName | Select-object DisplayName,LastLogonTime,WhenCreated,UserPrincipalName,MailboxTypeDetail} | Export-Csv 'D:\scriptresult.csv'


NEW

Import-csv c:\new_folder\himanshu.csv | foreach {$email = $_.emailid 

Get-MailboxStatistics -identity $email | Select-Object DisplayName,@{Name='Email';Expression={$email}},LastLogonTime

} | Export-Csv -Path c:\new_folder\lastlogin-7-5-2024.csv -NoTypeInformation

No comments: