If you need to export a list of user mailboxes (because your boss is making you or you simply have nothing better to do), it is quite an easy task if you have Exchange 2007 and up because of PowerShell snapins.
You can just fire up PowerShell and import the Exchange 2010 Module.
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Then:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | select-object Database, DisplayName, TotalItemSize, TotalDeletedItemSize | Sort-Object Database
Or you can export to CSV like so: Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | select-object Database, DisplayName, TotalItemSize, TotalDeletedItemSize | Sort-Object Database | Export-Csv .\Mailboxes.CSV -NoTypeInformation
But what if you’re still in survival mode with Exchange 2003?
You can use this script should you need to extract the list of user mailboxes from one or more Exchange 2003 servers.
This script will cough-out the following Fields.
- ServerName
- StorageGroupName
- StoreName
- MailboxGUID
- MailboxDisplayName
- LegacyDN
- Size
- TotalItems
- AssocContentCount
- DeletedMessageSizeExtended
- StorageLimitInfo
- LastLoggedOnUserAccount
- LastLogOnTime
- LastLogOffTime
- DateDiscoveredAbsentAbsentDaysInDS
This script reads the list of servers to be queried from a file called ServerList.ini. Be sure to create this file and populate it with the server names before running this script.
It runs in this order:
1. Read list of server from ServerList.ini 2. Query each servers and extract information 3. Save information to “ExchangeMBX.txt”
'========================================================================== ' ' NAME: ExtractMBXInfo.vbs ' ' AUTHOR: june.castillote@gmail.com ' DATE : 10/01/2011 ' ' COMMENT: This is for extracting the list of mailboxes from specified servers in the "serverlist.ini" file. ' FILES : 1. ExtractMBXInfo.vbs - main script ' 2. ServerList.ini - file containing the list of servers for the query. ' USAGE : cscript ExtractMBXInfo.vbs '========================================================================== Option Explicit On Error Resume Next Dim t1, t2, t3, d1, d2, d3 Dim strComputer '========================================================================== Dim FileToWrite, FileToRead, fsoWrite, fsoRead Set fsoWrite = CreateObject("Scripting.FileSystemObject") Set fsoRead = CreateObject("Scripting.FileSystemObject") Set FileToWrite = fsoWrite.CreateTextFile("ExchangeMBX.txt") Set FileToRead = fsoRead.OpenTextFile("ServerList.ini") Dim objWMIService Dim colItems Dim objItem Dim i 'Header row FileToWrite.WriteLine "Server" & vbTab & "Storage Group" & vbTab & "Mail Store" & vbTab & "Mailbox GUID" & vbTab & "Display Name" & vbTab & "LegacyDN" & vbTab & "Size" & vbTab & "Item Count" & vbTab & "Associated Content Count" & vbTab & "Deleted Message Size" & vbTab & "Date Absent" & vbTab & "Storage Limit Level" & vbtab & "Last LogOn Account" & vbtab & "Last LogOn Time" & vbTab & "Last LogOff Time" 'Iterate through the list of servers Do While Not FileToRead.AtEndOfStream strComputer = FileToRead.ReadLine() WScript.Echo Now & " : Connecting to " & strComputer Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & _ "\ROOT\MicrosoftExchangeV2") WScript.Echo Now & " : Running Query on " & strComputer Set colItems = objWMIService.ExecQuery _ ("Select * from Exchange_Mailbox") For Each objItem in colItems If objItem.LastLogOnTime <> "" Then t1=WMIDateStringToDate(objItem.LastLogonTime) Else t1 = "" End If If objItem.LastLogOffTime <> "" Then t2=WMIDateStringToDate(objItem.LastLogOffTime) Else t2 = "" End If If objItem.DateDiscoveredAbsentAbsentDaysInDS <> "" Then t3=WMIDateStringToDate(objItem.DateDiscoveredAbsentInDS) Else t3="" End If FileToWrite.WriteLine objItem.ServerName & vbTab & objItem.StorageGroupName & vbTab & objItem.StoreName & vbTab & objItem.MailboxGUID & vbTab & objItem.MailboxDisplayName & vbTab & objItem.LegacyDN & vbTab & objItem.Size & vbTab & objItem.TotalItems & vbTab & objItem.AssocContentCount & vbTab & objItem.DeletedMessageSizeExtended & vbTab & t3 & vbTab & objItem.StorageLimitInfo & vbTab & objItem.LastLoggedOnUserAccount & vbTab & t1 & vbTab & t2 Next Loop WScript.Echo Now & " : End - Saved to ExchangeMBX.txt" 'To convert WMI time to Standard time format Function WMIDateStringToDate(dtmInstallDate) WMIDateStringToDate = CDate(Mid(dtmInstallDate, 5, 2) & "/" & _ Mid(dtmInstallDate, 7, 2) & "/" & Left(dtmInstallDate, 4) _ & " " & Mid (dtmInstallDate, 9, 2) & ":" & _ Mid(dtmInstallDate, 11, 2) & ":" & Mid(dtmInstallDate, _ 13, 2)) End Function FileToRead.Close FileToWrite.Close Set FileToRead = Nothing Set FileToWrite = Nothing