#Exchange #Exchange2010 #Powershell
You know when you run Get-Mailbox using the Exchange Management Shell, and if your unlucky like me you have a shed load of mailboxes that are “invalid” for various reasons. .. and when you run Get-Maibox you get red text that says the mailbox has an error, but you don’t know which mailbox.
So I knocked this up .. Enjoy .. as you may have guessed the result is InvalidMBX.html. Not the most glamorous but does the trick
$allMailboxes = get-mailbox -ResultSize unlimited
$invalid = $allMailboxes | where {$_.IsValid -eq $False}
$InvalidMBX = @()
ForEach ($MBX in $Invalid){
$tmpTable = “” | Select Name, Email, PropertyName,Description, InvalidData
$mbxvalid = $MBX.Validate()
$mbxValid | ForEach{
$tmpTable.Name = $MBX.name
$tmpTable.Email = $MBX.PrimarySmtpAddress.ToString()
$tmpTable.PropertyName = $_.PropertyName
$tmpTable.Description = $_.Description
$tmpTable.InvalidData = $_.InvalidData
$InvalidMBX += $tmpTable
}
}
$InvalidMBX | ConvertTo-Html | Out-File InvalidMBX.html