Created
February 8, 2023 15:22
-
-
Save Fantasillion/6d4f9a35c83c61e4eaa218f289477e1a to your computer and use it in GitHub Desktop.
Get Exchange Online Archive Last Run Status for each user
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
$Mbx = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | |
$Report = @() | |
ForEach ($M in $Mbx) { | |
$LastProcessed = $Null | |
Write-Host "Processing" $M.DisplayName | |
$Log = Export-MailboxDiagnosticLogs -Identity $M.Alias -ExtendedProperties | |
$xml = [xml]($Log.MailboxLog) | |
$LastProcessed = ($xml.Properties.MailboxTable.Property | ? {$_.Name -like "*ELCLastSuccessTimestamp*"}).Value | |
$ItemsArchived = $xml.Properties.MailboxTable.Property | ? {$_.Name -like "*ElcLastRunArchivedFromRootItemCount*"} | |
If ($LastProcessed -eq $Null) { | |
$LastProcessed = "Not processed"} | |
$ReportLine = [PSCustomObject]@{ | |
User = $M.DisplayName | |
LastProcessed = $LastProcessed | |
ItemsArchived = $ItemsArchived.Value} | |
$Report += $ReportLine | |
} | |
$Report | Select User, LastProcessed, ItemsDeleted | |
$Report | Out-GridView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment