Recently one of our technicians was working on migration of mailboxes from an on-premise Exchange server to the online services of Office 365. During this process we had found that the on-site Exchange server was of the 2007 variety. Working with the first public iteration of PowerShell, we created the following hammer to list all mailboxes in Exchange 2007 and export to a CSV for viewing pleasure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
$CSVPath = "C:\Documents and Settings\twahadmin\My Documents\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 } $oMailboxes = get-Mailbox $oMailboxes | ForEach-Object { $oMailbox = $_ $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 |
Hi man,
Congratulations on the initiative, this script is very helpful. Good luck in your professional career.