Exchange 2003 Mailbox Powershell Report

Posted by in Exchange, PowerShell

Right, this will probably be so horrifically out-of-date for some people, but recently I’ve been doing a few Exchange 2003 migrations and have realised the importance of getting all the data you need before performing these migrations is quite high.

Sure, you can export the data you find in Exchange System Manager but what if you want other details like PrimarySMTPAddress or whether Email Address Policy is enabled for the user, or what their quotas are?

This is where this script comes in.

This script will give you a CSV report showing all mailboxes hosted on the Exchange 2003 server along with plenty of other details to aid in your migrations.

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
################################################################################
################# Exchange 2003 Mailbox Report by Matt Ellis ###################
################################################################################
 
# Contact Me
# ----------
 
# Web: http://mattellis.me
# Twitter: http://twitter.com/ellismessaging (@ellismessaging)
 
# Syntax
# ------
 
# The script has two switches, one of which is mandatory:
 
# 1. -ServerName (mandatory)
# For example: .\Get-Exchange2003MailboxReport.ps1 -ServerName EX2K3SRV01 
 
# 2. -ReportPath (optional)
# For example: .\Get-Exchange2003MailboxReport.ps1 -ServerName EX2K3SRV01 -ReportPath "D:\Temp\"
 
Param (
	[Parameter(Mandatory = $True)]
	$ServerName,
	[Parameter(Mandatory = $False)]
	$ReportPath
)
 
$Date = Get-Date -format "yyyyMMdd"
 
If ($ReportPath) {
	If ($ReportPath[-1] -ne "\") {
		$ReportPath += "\"
	}
	$OutFileTemp = "$ReportPath$ServerName-$Date.txt"
	$OutFile = "$ReportPath$ServerName-$Date.csv"
} Else {
	$OutFileTemp = "$ServerName-$Date.txt"
	$OutFile = "$ServerName-$Date.csv"
}
 
"Alias" + "^" + "DisplayName" + "^" + "MailboxSizeMB"  + "^" + "ServerName" `
+ "^" + "Database" + "^" + "PrimarySMTPAddress" + "^" + "EmailAddressPolicyEnabled" `
+ "^" + "HiddenFromGAL" + "^" + "UseDatabaseQuotaDefaults"  + "^" + "IssueWarningQuota" `
+ "^" + "ProhibitSendQuota" | Out-File $OutFileTemp -Force
 
$Users = Get-WmiObject -ComputerName $ServerName -Namespace root\MicrosoftExchangeV2 -Class Exchange_Mailbox
 
ForEach ($User in $Users) {
	$GM = Get-Mailbox -Identity $User.MailboxGUID
	If ($GM) {
		$MailboxSizeMB = "{0:N0}" -f ([decimal]$User.Size/1024)
		#$MailboxSizeGB = "{0:N2}" -f ([decimal]$MailboxSizeMB/1024)
		$LastLogon = $User.ConvertToDateTime($User.LastLogonTime)
 
		$GM.Alias + "^" + $GM.DisplayName + "^" + $MailboxSizeMB  + "^" + $GM.ServerName `
		+ "^" + $GM.Database + "^" + $GM.PrimarySMTPAddress + "^" + $GM.EmailAddressPolicyEnabled `
		+ "^" + $GM.HiddenFromAddressListsEnabled + "^" + [bool]$GM.UseDatabaseQuotaDefaults `
		+ "^" + $GM.IssueWarningQuota + "^" + $GM.ProhibitSendQuota | Out-File $OutFileTemp -Append
	}
}
 
Import-Csv $OutFileTemp -Delimiter "^" | Export-Csv -Path $OutFile -NoTypeInformation -Force
Del $OutFileTemp
Write-Host -NoNewline "Report file created:" (Resolve-Path $OutFile).Path