this Script will Export the mailboxes who has been not been logged in or has not been logged in within spcific time/day
it's very simple i alway try to write simple script that everybody should understand and make it work and modifiy as they wish to work with their environment
download it to get the full working please not forget to rate it
############################################################################## Export Mailbox Users, has not been logged in within X Days to CSV file# # Rahmatullah Fedayizada# # # Email: rahmat_fedayizada@hotmail.com# ============================================================================
#############################################################################
# Export Mailbox Users, has not been logged in within X Days to CSV file
#
# Rahmatullah Fedayizada
#
#
# Email: rahmat_fedayizada@hotmail.com
# ============================================================================
#change the days has not been logged in
$daysnotloggedin = "90"
#getmailboxes
$mailboxes = Get-Mailbox -ResultSize unlimited
foreach($mailbox in $mailboxes)
{
$Alia = $mailbox.Alias
$tod = (Get-Date).AddDays(-$daysnotloggedin)
Get-MailboxStatistics -Identity $Alia | Where-Object {$_.lastLogonTime -lt $tod} | Select-Object DisplayName,ItemCount,LastLogonTime | Export-Csv -Path Z:\ad\expring.csv -Append
}
############################################################################# # Export Mailbox Users, has not been logged in within X Days to CSV file # # Rahmatullah Fedayizada # # # Email: rahmat_fedayizada@hotmail.com # ============================================================================ #change the days has not been logged in $daysnotloggedin = "90" #getmailboxes $mailboxes = Get-Mailbox -ResultSize unlimited foreach($mailbox in $mailboxes) { $Alia = $mailbox.Alias $tod = (Get-Date).AddDays(-$daysnotloggedin) Get-MailboxStatistics -Identity $Alia | Where-Object {$_.lastLogonTime -lt $tod} | Select-Object DisplayName,ItemCount,LastLogonTime | Export-Csv -Path Z:\ad\expring.csv -Append }