Place holder for the post, need to make something snappy
$CSVPath = “C:\scripts\MailboxData.csv”
$oMailboxData = @()
# Build this damn template because of the useless original release of PowerShell
$oMailboxInfoTemplate = New-Object PSObject
@(“DisplayName”,”UserPrincipalName”,”RecipientTypeDetails”,”PrimarySMTPAddress”,”ItemCount”,”TotalItemSize”,”WhenCreated”,”LastLogonTime”) | ForEach-Object {
$oMailboxInfoTemplate | Add-Member -MemberType NoteProperty -Name $_ -Value $null
}
get-content .\mailboxes.txt | foreach-object {
$oMailbox = get-mailbox $_
$oMailboxStats = Get-MailboxStatistics $_
$oMailboxInfo = $oMailboxInfoTemplate | Select *
$oMailboxInfo.DisplayName = $oMailbox.DisplayName
$oMailboxInfo.UserPrincipalName = $oMailbox.UserPrincipalName
$oMailboxInfo.RecipientTypeDetails = $oMailbox.RecipientTypeDetails
$oMailboxInfo.PrimarySMTPAddress = $oMailbox.PrimarySMTPAddress
$oMailboxInfo.ItemCount = $oMailboxStats.ItemCount
$oMailboxInfo.TotalItemSize = $oMailboxStats.TotalItemSize
$oMailboxInfo.WhenCreated = $oMailbox.WhenCreated
$oMailboxInfo.LastLogonTime = $oMailboxStats.LastLogonTime
$oMailboxData += $oMailboxInfo
}
$oMailboxData | Export-CSV -NoClobber -NoTypeInformation -Path $CSVPath