Created
August 21, 2023 21:08
-
-
Save jessewolcott/81332fa3a44d5738ffcd88dc19f78d5a to your computer and use it in GitHub Desktop.
Find Last Exchange and AD Login!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Emails = @( | |
"test@contoso.com" | |
"Otherguy@fabrikam.com" | |
) | |
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn | |
$Results = foreach ($Email in $Emails){ | |
$LLT = (Get-MailboxStatistics -Identity $Email).LastLogonTime | |
$ADLLT = (Get-ADUser -Filter {UserPrincipalName -eq $Email} -ErrorAction SilentlyContinue -Properties *) | |
[PSCustomObject]@{ | |
Mailbox = $Email | |
'Exchange Last Logon' = $LLT | |
'AD Last Logon' = $ADlLT.LastLogonDate | |
'Created' = $ADLLT.whenCreated | |
} | |
} | |
$Results | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment