Skip to content

Instantly share code, notes, and snippets.

@jessewolcott
Created August 21, 2023 21:08
Show Gist options
  • Save jessewolcott/81332fa3a44d5738ffcd88dc19f78d5a to your computer and use it in GitHub Desktop.
Save jessewolcott/81332fa3a44d5738ffcd88dc19f78d5a to your computer and use it in GitHub Desktop.
Find Last Exchange and AD Login!
$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