Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: Mon, 7 Apr 2008 12:01:31 +0100,    group: microsoft.public.exchange.tools        back       


Mailbox sizes   
Hi All,

I'm using Exchange 2003. 6 servers each with 4 SG and I was wondering if 
there was any way or even a tool that can tell me the largest 25 (or 
whatever) mailboxes.

This is we can monitor who is using what disk space

Regards

Andy
date: Mon, 7 Apr 2008 12:01:31 +0100   author:   Andy White am

Re: Mailbox sizes   
Andy White wrote:
> Hi All,
> 
> I'm using Exchange 2003. 6 servers each with 4 SG and I was wondering if 
> there was any way or even a tool that can tell me the largest 25 (or 
> whatever) mailboxes.
> 
> This is we can monitor who is using what disk space
> 
> Regards
> 
> Andy 
> 
> 
I picked this up somewhere (hope it helps)

[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")


function getMailboxSizes(){

$mstoresquotas.clear()
$msTable.clear()
$usrquotas.clear()

get-mailboxdatabase -server $snServerNameDrop.SelectedItem.ToString() | 
ForEach-Object{
	$_.identity
	$_.ProhibitSendReceiveQuota
	if ($_.IsUnlimited -ne $true){
		$mstoresquotas.add($_.identity,$_.ProhibitSendReceiveQuota)
	}
	
}

$usrquotas = @{ }
Get-Mailbox -server $snServerNameDrop.SelectedItem.ToString() 
-ResultSize Unlimited | foreach-object{
	if($_.ProhibitSendQuota -ne "unlimited"){
		$usrquotas.add($_.ExchangeGuid,$_.ProhibitSendReceiveQuota)
	}
}

if ($mtTypeDrop.SelectedItem -ne $null){
	if ($mtTypeDrop.SelectedItem.ToString() -eq "Disconnected"){
		get-mailboxstatistics -Server 
$snServerNameDrop.SelectedItem.ToString() | Where {$_.DisconnectDate -ne 
$null} | ForEach-Object{
		$quQuota = "0"
		if ($_.UseDatabaseQuotaDefaults -eq $false){
			if ($usrquotas.ContainsKey($_.MailboxGUID)){
				$quQuota = "{0:P0}" -f 
($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
			}
		}
		else{
			if ($mstoresquotas.ContainsKey($_.database)){
				$quQuota = "{0:P0}" -f 
($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
		}
		$icount = 0
		$tisize = 0
		$disize = 0
		if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
		if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
		if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
$_.TotalItemSize.Value.ToMB()}
		if ($_.TotalDeletedItemSize.Value.ToMB() -ne $null){$disize = 
$_.TotalDeletedItemSize.Value.ToMB()}
		
		$msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%",""))
		}
	}
	else{	get-mailboxstatistics -Server 
$snServerNameDrop.SelectedItem.ToString() | Where {$_.DisconnectDate -eq 
$null} | ForEach-Object{
		$quQuota = "0"
		if ($_.UseDatabaseQuotaDefaults -eq $false){
			if ($usrquotas.ContainsKey($_.MailboxGUID)){
				$quQuota = "{0:P0}" -f 
($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
			}
		}
		else{
			if ($mstoresquotas.ContainsKey($_.database)){
				$quQuota = "{0:P0}" -f 
($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
		}
		$icount = 0
		$tisize = 0
		$disize = 0
		if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
		if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
		if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
$_.TotalItemSize.Value.ToMB()}
		if ($_.TotalDeletedItemSize.Value.ToKB() -ne $null){$disize = 
$_.TotalDeletedItemSize.Value.ToKB()}
		$msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%",""))
		}

	}
}
else{
		get-mailboxstatistics -Server 
$snServerNameDrop.SelectedItem.ToString() | ForEach-Object{
		$quQuota = "0"
		if ($_.UseDatabaseQuotaDefaults -eq $false){
			if ($usrquotas.ContainsKey($_.MailboxGUID)){
				$quQuota = "{0:P0}" -f 
($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
			}
		}
		else{
			if ($mstoresquotas.ContainsKey($_.database)){
				$quQuota = "{0:P0}" -f 
($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
		}
	        $icount = 0
		$tisize = 0
		$disize = 0
		if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
		if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
		if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
$_.TotalItemSize.Value.ToMB()}
		if ($_.TotalDeletedItemSize.Value.ToKB() -ne $null){$disize = 
$_.TotalDeletedItemSize.Value.ToKB()}
		$msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%",""))
	}

}
write-host $fstring

$dgDataGrid.DataSource = $msTable

}


function GetFolderSizes(){
$fsTable.clear()
$snServername = $snServerNameDrop.SelectedItem.ToString()
write-host $dgDataGrid.CurrentCell.RowIndex
$siSIDToSearch = get-user 
$msTable.DefaultView[$dgDataGrid.CurrentCell.RowIndex][0]
write-host $siSIDToSearch.SamAccountName.ToString()
Get-MailboxFolderStatistics $siSIDToSearch.SamAccountName.ToString() | 
ForEach-Object{
	$ficount = 0
	$fisize = 0
	$fsisize = 0
	$fscount = 0
	$fname = $_.Name
	if ($_.FolderSize -ne $null){$fsisize = 
[math]::round(($_.FolderSize/1mb),2)}
	if ($_.ItemsInFolder -ne $null){$ficount = $_.ItemsInFolder}
	if ($_.ItemsInFolderAndSubfolders -ne $null){$fscount = 
$_.ItemsInFolderAndSubfolders}
	if ($_.FolderAndSubfolderSize -ne $null){$fsisize = 
[math]::round(($_.FolderAndSubfolderSize/1mb),2)}
	$fsTable.Rows.add($fname,$ficount,$fsisize,$fscount,$fsisize)
}
$dgDataGrid1.DataSource = $fsTable
}

function ExportMBcsv{

$exFileName = new-object System.Windows.Forms.saveFileDialog
$exFileName.DefaultExt = "csv"
$exFileName.Filter = "csv files (*.csv)|*.csv"
$exFileName.InitialDirectory = "c:\temp"
$exFileName.ShowDialog()
if ($exFileName.FileName -ne ""){
	$logfile = new-object IO.StreamWriter($exFileName.FileName,$true)
	$logfile.WriteLine("UserName,# Items,MB Size(MB),DelItems(KB)")
	foreach($row in $msTable.Rows){
		$logfile.WriteLine("`"" + $row[0].ToString() + "`"," + 
$row[1].ToString() + "," + $row[2].ToString() + "," + $row[3].ToString())
	}
	$logfile.Close()
}
}

function ExportFScsv{

$exFileName = new-object System.Windows.Forms.saveFileDialog
$exFileName.DefaultExt = "csv"
$exFileName.Filter = "csv files (*.csv)|*.csv"
$exFileName.InitialDirectory = "c:\temp"
$exFileName.ShowDialog()
if ($exFileName.FileName -ne ""){
	$logfile = new-object IO.StreamWriter($exFileName.FileName,$true)
	$logfile.WriteLine("DisplayName,# Items,Folder Size(MB),# Items + 
Sub,Folder Size + Sub(MB)")
	foreach($row in $fsTable.Rows){
		$logfile.WriteLine("`"" + $row[0].ToString() + "`"," + 
$row[1].ToString() + "," + $row[2].ToString() + "," + $row[3].ToString() 
+ "," + $row[4].ToString())
	}
	$logfile.Close()
}
}

$usrquotas = @{ }
$mstoresquotas = @{ }
$form = new-object System.Windows.Forms.form
$global:LastFolder = ""
# Add DataTable

$Dataset = New-Object System.Data.DataSet
$fsTable = New-Object System.Data.DataTable
$fsTable.TableName = "Folder Sizes"
$fsTable.Columns.Add("DisplayName")
$fsTable.Columns.Add("# Items",[int64])
$fsTable.Columns.Add("Folder Size(MB)",[int64])
$fsTable.Columns.Add("# Items + Sub",[int64])
$fsTable.Columns.Add("Folder Size + Sub(MB)",[int64])
$Dataset.tables.add($fsTable)

$msTable = New-Object System.Data.DataTable
$msTable.TableName = "Mailbox Sizes"
$msTable.Columns.Add("UserName")
$msTable.Columns.Add("# Items",[int64])
$msTable.Columns.Add("MB Size(MB)",[int64])
$msTable.Columns.Add("DelItems(MB)",[int64])
$msTable.Columns.Add("Quota Used",[int64])
$Dataset.tables.add($msTable)

# Add Server DropLable
$snServerNamelableBox = new-object System.Windows.Forms.Label
$snServerNamelableBox.Location = new-object System.Drawing.Size(10,20)
$snServerNamelableBox.size = new-object System.Drawing.Size(80,20)
$snServerNamelableBox.Text = "ServerName"
$form.Controls.Add($snServerNamelableBox)

# Add Server Drop Down
$snServerNameDrop = new-object System.Windows.Forms.ComboBox
$snServerNameDrop.Location = new-object System.Drawing.Size(90,20)
$snServerNameDrop.Size = new-object System.Drawing.Size(100,30)
get-mailboxserver | ForEach-Object{$snServerNameDrop.Items.Add($_.Name)}
$snServerNameDrop.Add_SelectedValueChanged({getMailboxSizes})
$form.Controls.Add($snServerNameDrop)

# Add Mailbox Type DropLable
$mtTypeDroplableBox = new-object System.Windows.Forms.Label
$mtTypeDroplableBox.Location = new-object System.Drawing.Size(200,20)
$mtTypeDroplableBox.size = new-object System.Drawing.Size(80,20)
$mtTypeDroplableBox.Text = "MailboxType"
$form.Controls.Add($mtTypeDroplableBox)

# Add Mailbox Type Drop Down
$mtTypeDrop = new-object System.Windows.Forms.ComboBox
$mtTypeDrop.Location = new-object System.Drawing.Size(290,20)
$mtTypeDrop.Size = new-object System.Drawing.Size(100,30)
$mtTypeDrop.Items.Add("Disconnected")
$mtTypeDrop.Items.Add("Connected")
$mtTypeDrop.Add_SelectedValueChanged({if ($snServerNameDrop.SelectedItem 
-ne $null){getMailboxSizes}})
$form.Controls.Add($mtTypeDrop)

# Add Export MB Button

$exButton1 = new-object System.Windows.Forms.Button
$exButton1.Location = new-object System.Drawing.Size(10,560)
$exButton1.Size = new-object System.Drawing.Size(125,20)
$exButton1.Text = "Export Mailbox Grid"
$exButton1.Add_Click({ExportMBcsv})
$form.Controls.Add($exButton1)

# Add Export FG Button

$exButton2 = new-object System.Windows.Forms.Button
$exButton2.Location = new-object System.Drawing.Size(550,560)
$exButton2.Size = new-object System.Drawing.Size(135,20)
$exButton2.Text = "Export FolderSize Grid"
$exButton2.Add_Click({ExportFScsv})
$form.Controls.Add($exButton2)

# Add DataGrid View

$dgDataGrid = new-object System.windows.forms.DataGridView
$dgDataGrid.Location = new-object System.Drawing.Size(10,50)
$dgDataGrid.size = new-object System.Drawing.Size(530,500)
$dgDataGrid.AutoSizeRowsMode = "AllHeaders"
$form.Controls.Add($dgDataGrid)

$dgDataGrid1 = new-object System.windows.forms.DataGridView
$dgDataGrid1.Location = new-object System.Drawing.Size(550,50)
$dgDataGrid1.size = new-object System.Drawing.Size(450,500)
$dgDataGrid1.AutoSizeRowsMode = "AllHeaders"
$form.Controls.Add($dgDataGrid1)

# folder Size Button

$fsizeButton = new-object System.Windows.Forms.Button
$fsizeButton.Location = new-object System.Drawing.Size(500,19)
$fsizeButton.Size = new-object System.Drawing.Size(120,23)
$fsizeButton.Text = "Get Folder Size"
$fsizeButton.visible = $True
$fsizeButton.Add_Click({GetFolderSizes})
$form.Controls.Add($fsizeButton)



$form.Text = "Exchange 2007 Mailbox Size Form"
$form.size = new-object System.Drawing.Size(1000,620)
$form.autoscroll = $true
$form.topmost = $true
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()
date: Mon, 07 Apr 2008 10:03:52 -0500   author:   kelly goff

Re: Mailbox sizes   
The script is for Powershell, are you sure it works against Exchange 2003?

Christian

"kelly goff"  wrote in message 
news:OzADuCMmIHA.536@TK2MSFTNGP06.phx.gbl...
> Andy White wrote:
>> Hi All,
>>
>> I'm using Exchange 2003. 6 servers each with 4 SG and I was wondering if 
>> there was any way or even a tool that can tell me the largest 25 (or 
>> whatever) mailboxes.
>>
>> This is we can monitor who is using what disk space
>>
>> Regards
>>
>> Andy
> I picked this up somewhere (hope it helps)
>
> [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
> [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
>
>
> function getMailboxSizes(){
>
> $mstoresquotas.clear()
> $msTable.clear()
> $usrquotas.clear()
>
> get-mailboxdatabase -server $snServerNameDrop.SelectedItem.ToString() | 
> ForEach-Object{
> $_.identity
> $_.ProhibitSendReceiveQuota
> if ($_.IsUnlimited -ne $true){
> $mstoresquotas.add($_.identity,$_.ProhibitSendReceiveQuota)
> }
>
> }
>
> $usrquotas = @{ }
> Get-Mailbox -server $snServerNameDrop.SelectedItem.ToString() -ResultSize 
> Unlimited | foreach-object{
> if($_.ProhibitSendQuota -ne "unlimited"){
> $usrquotas.add($_.ExchangeGuid,$_.ProhibitSendReceiveQuota)
> }
> }
>
> if ($mtTypeDrop.SelectedItem -ne $null){
> if ($mtTypeDrop.SelectedItem.ToString() -eq "Disconnected"){
> get-mailboxstatistics -Server $snServerNameDrop.SelectedItem.ToString() | 
> Where {$_.DisconnectDate -ne $null} | ForEach-Object{
> $quQuota = "0"
> if ($_.UseDatabaseQuotaDefaults -eq $false){
> if ($usrquotas.ContainsKey($_.MailboxGUID)){
> $quQuota = "{0:P0}" -f 
> ($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
> }
> }
> else{
> if ($mstoresquotas.ContainsKey($_.database)){
> $quQuota = "{0:P0}" -f 
> ($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
> }
> $icount = 0
> $tisize = 0
> $disize = 0
> if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
> if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
> if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
> $_.TotalItemSize.Value.ToMB()}
> if ($_.TotalDeletedItemSize.Value.ToMB() -ne $null){$disize = 
> $_.TotalDeletedItemSize.Value.ToMB()}
>
> $msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%",""))
> }
> }
> else{ get-mailboxstatistics -Server 
> $snServerNameDrop.SelectedItem.ToString() | Where {$_.DisconnectDate -eq 
> $null} | ForEach-Object{
> $quQuota = "0"
> if ($_.UseDatabaseQuotaDefaults -eq $false){
> if ($usrquotas.ContainsKey($_.MailboxGUID)){
> $quQuota = "{0:P0}" -f 
> ($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
> }
> }
> else{
> if ($mstoresquotas.ContainsKey($_.database)){
> $quQuota = "{0:P0}" -f 
> ($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
> }
> $icount = 0
> $tisize = 0
> $disize = 0
> if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
> if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
> if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
> $_.TotalItemSize.Value.ToMB()}
> if ($_.TotalDeletedItemSize.Value.ToKB() -ne $null){$disize = 
> $_.TotalDeletedItemSize.Value.ToKB()}
> $msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%",""))
> }
>
> }
> }
> else{
> get-mailboxstatistics -Server $snServerNameDrop.SelectedItem.ToString() | 
> ForEach-Object{
> $quQuota = "0"
> if ($_.UseDatabaseQuotaDefaults -eq $false){
> if ($usrquotas.ContainsKey($_.MailboxGUID)){
> $quQuota = "{0:P0}" -f 
> ($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
> }
> }
> else{
> if ($mstoresquotas.ContainsKey($_.database)){
> $quQuota = "{0:P0}" -f 
> ($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
> }
>         $icount = 0
> $tisize = 0
> $disize = 0
> if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
> if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
> if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
> $_.TotalItemSize.Value.ToMB()}
> if ($_.TotalDeletedItemSize.Value.ToKB() -ne $null){$disize = 
> $_.TotalDeletedItemSize.Value.ToKB()}
> $msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%",""))
> }
>
> }
> write-host $fstring
>
> $dgDataGrid.DataSource = $msTable
>
> }
>
>
> function GetFolderSizes(){
> $fsTable.clear()
> $snServername = $snServerNameDrop.SelectedItem.ToString()
> write-host $dgDataGrid.CurrentCell.RowIndex
> $siSIDToSearch = get-user 
> $msTable.DefaultView[$dgDataGrid.CurrentCell.RowIndex][0]
> write-host $siSIDToSearch.SamAccountName.ToString()
> Get-MailboxFolderStatistics $siSIDToSearch.SamAccountName.ToString() | 
> ForEach-Object{
> $ficount = 0
> $fisize = 0
> $fsisize = 0
> $fscount = 0
> $fname = $_.Name
> if ($_.FolderSize -ne $null){$fsisize = 
> [math]::round(($_.FolderSize/1mb),2)}
> if ($_.ItemsInFolder -ne $null){$ficount = $_.ItemsInFolder}
> if ($_.ItemsInFolderAndSubfolders -ne $null){$fscount = 
> $_.ItemsInFolderAndSubfolders}
> if ($_.FolderAndSubfolderSize -ne $null){$fsisize = 
> [math]::round(($_.FolderAndSubfolderSize/1mb),2)}
> $fsTable.Rows.add($fname,$ficount,$fsisize,$fscount,$fsisize)
> }
> $dgDataGrid1.DataSource = $fsTable
> }
>
> function ExportMBcsv{
>
> $exFileName = new-object System.Windows.Forms.saveFileDialog
> $exFileName.DefaultExt = "csv"
> $exFileName.Filter = "csv files (*.csv)|*.csv"
> $exFileName.InitialDirectory = "c:\temp"
> $exFileName.ShowDialog()
> if ($exFileName.FileName -ne ""){
> $logfile = new-object IO.StreamWriter($exFileName.FileName,$true)
> $logfile.WriteLine("UserName,# Items,MB Size(MB),DelItems(KB)")
> foreach($row in $msTable.Rows){
> $logfile.WriteLine("`"" + $row[0].ToString() + "`"," + $row[1].ToString() 
> + "," + $row[2].ToString() + "," + $row[3].ToString())
> }
> $logfile.Close()
> }
> }
>
> function ExportFScsv{
>
> $exFileName = new-object System.Windows.Forms.saveFileDialog
> $exFileName.DefaultExt = "csv"
> $exFileName.Filter = "csv files (*.csv)|*.csv"
> $exFileName.InitialDirectory = "c:\temp"
> $exFileName.ShowDialog()
> if ($exFileName.FileName -ne ""){
> $logfile = new-object IO.StreamWriter($exFileName.FileName,$true)
> $logfile.WriteLine("DisplayName,# Items,Folder Size(MB),# Items + 
> Sub,Folder Size + Sub(MB)")
> foreach($row in $fsTable.Rows){
> $logfile.WriteLine("`"" + $row[0].ToString() + "`"," + $row[1].ToString() 
> + "," + $row[2].ToString() + "," + $row[3].ToString() + "," + 
> $row[4].ToString())
> }
> $logfile.Close()
> }
> }
>
> $usrquotas = @{ }
> $mstoresquotas = @{ }
> $form = new-object System.Windows.Forms.form
> $global:LastFolder = ""
> # Add DataTable
>
> $Dataset = New-Object System.Data.DataSet
> $fsTable = New-Object System.Data.DataTable
> $fsTable.TableName = "Folder Sizes"
> $fsTable.Columns.Add("DisplayName")
> $fsTable.Columns.Add("# Items",[int64])
> $fsTable.Columns.Add("Folder Size(MB)",[int64])
> $fsTable.Columns.Add("# Items + Sub",[int64])
> $fsTable.Columns.Add("Folder Size + Sub(MB)",[int64])
> $Dataset.tables.add($fsTable)
>
> $msTable = New-Object System.Data.DataTable
> $msTable.TableName = "Mailbox Sizes"
> $msTable.Columns.Add("UserName")
> $msTable.Columns.Add("# Items",[int64])
> $msTable.Columns.Add("MB Size(MB)",[int64])
> $msTable.Columns.Add("DelItems(MB)",[int64])
> $msTable.Columns.Add("Quota Used",[int64])
> $Dataset.tables.add($msTable)
>
> # Add Server DropLable
> $snServerNamelableBox = new-object System.Windows.Forms.Label
> $snServerNamelableBox.Location = new-object System.Drawing.Size(10,20)
> $snServerNamelableBox.size = new-object System.Drawing.Size(80,20)
> $snServerNamelableBox.Text = "ServerName"
> $form.Controls.Add($snServerNamelableBox)
>
> # Add Server Drop Down
> $snServerNameDrop = new-object System.Windows.Forms.ComboBox
> $snServerNameDrop.Location = new-object System.Drawing.Size(90,20)
> $snServerNameDrop.Size = new-object System.Drawing.Size(100,30)
> get-mailboxserver | ForEach-Object{$snServerNameDrop.Items.Add($_.Name)}
> $snServerNameDrop.Add_SelectedValueChanged({getMailboxSizes})
> $form.Controls.Add($snServerNameDrop)
>
> # Add Mailbox Type DropLable
> $mtTypeDroplableBox = new-object System.Windows.Forms.Label
> $mtTypeDroplableBox.Location = new-object System.Drawing.Size(200,20)
> $mtTypeDroplableBox.size = new-object System.Drawing.Size(80,20)
> $mtTypeDroplableBox.Text = "MailboxType"
> $form.Controls.Add($mtTypeDroplableBox)
>
> # Add Mailbox Type Drop Down
> $mtTypeDrop = new-object System.Windows.Forms.ComboBox
> $mtTypeDrop.Location = new-object System.Drawing.Size(290,20)
> $mtTypeDrop.Size = new-object System.Drawing.Size(100,30)
> $mtTypeDrop.Items.Add("Disconnected")
> $mtTypeDrop.Items.Add("Connected")
> $mtTypeDrop.Add_SelectedValueChanged({if 
> ($snServerNameDrop.SelectedItem -ne $null){getMailboxSizes}})
> $form.Controls.Add($mtTypeDrop)
>
> # Add Export MB Button
>
> $exButton1 = new-object System.Windows.Forms.Button
> $exButton1.Location = new-object System.Drawing.Size(10,560)
> $exButton1.Size = new-object System.Drawing.Size(125,20)
> $exButton1.Text = "Export Mailbox Grid"
> $exButton1.Add_Click({ExportMBcsv})
> $form.Controls.Add($exButton1)
>
> # Add Export FG Button
>
> $exButton2 = new-object System.Windows.Forms.Button
> $exButton2.Location = new-object System.Drawing.Size(550,560)
> $exButton2.Size = new-object System.Drawing.Size(135,20)
> $exButton2.Text = "Export FolderSize Grid"
> $exButton2.Add_Click({ExportFScsv})
> $form.Controls.Add($exButton2)
>
> # Add DataGrid View
>
> $dgDataGrid = new-object System.windows.forms.DataGridView
> $dgDataGrid.Location = new-object System.Drawing.Size(10,50)
> $dgDataGrid.size = new-object System.Drawing.Size(530,500)
> $dgDataGrid.AutoSizeRowsMode = "AllHeaders"
> $form.Controls.Add($dgDataGrid)
>
> $dgDataGrid1 = new-object System.windows.forms.DataGridView
> $dgDataGrid1.Location = new-object System.Drawing.Size(550,50)
> $dgDataGrid1.size = new-object System.Drawing.Size(450,500)
> $dgDataGrid1.AutoSizeRowsMode = "AllHeaders"
> $form.Controls.Add($dgDataGrid1)
>
> # folder Size Button
>
> $fsizeButton = new-object System.Windows.Forms.Button
> $fsizeButton.Location = new-object System.Drawing.Size(500,19)
> $fsizeButton.Size = new-object System.Drawing.Size(120,23)
> $fsizeButton.Text = "Get Folder Size"
> $fsizeButton.visible = $True
> $fsizeButton.Add_Click({GetFolderSizes})
> $form.Controls.Add($fsizeButton)
>
>
>
> $form.Text = "Exchange 2007 Mailbox Size Form"
> $form.size = new-object System.Drawing.Size(1000,620)
> $form.autoscroll = $true
> $form.topmost = $true
> $form.Add_Shown({$form.Activate()})
> $form.ShowDialog()
date: Thu, 10 Apr 2008 22:23:59 +0200   author:   Christian Schindler

Re: Mailbox sizes   
I know it worked in a 2003 and 2007 environment. Don't know about a pure 
2003 environment.

Kelly

Christian Schindler wrote:
> The script is for Powershell, are you sure it works against Exchange 2003?
> 
> Christian
> 
> "kelly goff"  wrote in message 
> news:OzADuCMmIHA.536@TK2MSFTNGP06.phx.gbl...
>> Andy White wrote:
>>> Hi All,
>>>
>>> I'm using Exchange 2003. 6 servers each with 4 SG and I was wondering 
>>> if there was any way or even a tool that can tell me the largest 25 
>>> (or whatever) mailboxes.
>>>
>>> This is we can monitor who is using what disk space
>>>
>>> Regards
>>>
>>> Andy
>> I picked this up somewhere (hope it helps)
>>
>> [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
>> [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
>>
>>
>> function getMailboxSizes(){
>>
>> $mstoresquotas.clear()
>> $msTable.clear()
>> $usrquotas.clear()
>>
>> get-mailboxdatabase -server $snServerNameDrop.SelectedItem.ToString() 
>> | ForEach-Object{
>> $_.identity
>> $_.ProhibitSendReceiveQuota
>> if ($_.IsUnlimited -ne $true){
>> $mstoresquotas.add($_.identity,$_.ProhibitSendReceiveQuota)
>> }
>>
>> }
>>
>> $usrquotas = @{ }
>> Get-Mailbox -server $snServerNameDrop.SelectedItem.ToString() 
>> -ResultSize Unlimited | foreach-object{
>> if($_.ProhibitSendQuota -ne "unlimited"){
>> $usrquotas.add($_.ExchangeGuid,$_.ProhibitSendReceiveQuota)
>> }
>> }
>>
>> if ($mtTypeDrop.SelectedItem -ne $null){
>> if ($mtTypeDrop.SelectedItem.ToString() -eq "Disconnected"){
>> get-mailboxstatistics -Server 
>> $snServerNameDrop.SelectedItem.ToString() | Where {$_.DisconnectDate 
>> -ne $null} | ForEach-Object{
>> $quQuota = "0"
>> if ($_.UseDatabaseQuotaDefaults -eq $false){
>> if ($usrquotas.ContainsKey($_.MailboxGUID)){
>> $quQuota = "{0:P0}" -f 
>> ($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
>> }
>> }
>> else{
>> if ($mstoresquotas.ContainsKey($_.database)){
>> $quQuota = "{0:P0}" -f 
>> ($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
>> }
>> $icount = 0
>> $tisize = 0
>> $disize = 0
>> if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
>> if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
>> if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
>> $_.TotalItemSize.Value.ToMB()}
>> if ($_.TotalDeletedItemSize.Value.ToMB() -ne $null){$disize = 
>> $_.TotalDeletedItemSize.Value.ToMB()}
>>
>> $msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%","")) 
>>
>> }
>> }
>> else{ get-mailboxstatistics -Server 
>> $snServerNameDrop.SelectedItem.ToString() | Where {$_.DisconnectDate 
>> -eq $null} | ForEach-Object{
>> $quQuota = "0"
>> if ($_.UseDatabaseQuotaDefaults -eq $false){
>> if ($usrquotas.ContainsKey($_.MailboxGUID)){
>> $quQuota = "{0:P0}" -f 
>> ($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
>> }
>> }
>> else{
>> if ($mstoresquotas.ContainsKey($_.database)){
>> $quQuota = "{0:P0}" -f 
>> ($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
>> }
>> $icount = 0
>> $tisize = 0
>> $disize = 0
>> if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
>> if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
>> if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
>> $_.TotalItemSize.Value.ToMB()}
>> if ($_.TotalDeletedItemSize.Value.ToKB() -ne $null){$disize = 
>> $_.TotalDeletedItemSize.Value.ToKB()}
>> $msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%","")) 
>>
>> }
>>
>> }
>> }
>> else{
>> get-mailboxstatistics -Server 
>> $snServerNameDrop.SelectedItem.ToString() | ForEach-Object{
>> $quQuota = "0"
>> if ($_.UseDatabaseQuotaDefaults -eq $false){
>> if ($usrquotas.ContainsKey($_.MailboxGUID)){
>> $quQuota = "{0:P0}" -f 
>> ($_.TotalItemSize.Value.ToMB()/$usrquotas[$_.MailboxGUID].Value.ToMB())
>> }
>> }
>> else{
>> if ($mstoresquotas.ContainsKey($_.database)){
>> $quQuota = "{0:P0}" -f 
>> ($_.TotalItemSize.Value.ToMB()/$mstoresquotas[$_.database].Value.ToMB())}
>> }
>>         $icount = 0
>> $tisize = 0
>> $disize = 0
>> if ($_.DisplayName -ne $null){$dname = $_.DisplayName}
>> if ($_.ItemCount -ne $null){$icount = $_.ItemCount}
>> if ($_.TotalItemSize.Value.ToMB() -ne $null){$tisize = 
>> $_.TotalItemSize.Value.ToMB()}
>> if ($_.TotalDeletedItemSize.Value.ToKB() -ne $null){$disize = 
>> $_.TotalDeletedItemSize.Value.ToKB()}
>> $msTable.Rows.add($dname,$icount,$tisize,$disize,$quQuota.replace("%","")) 
>>
>> }
>>
>> }
>> write-host $fstring
>>
>> $dgDataGrid.DataSource = $msTable
>>
>> }
>>
>>
>> function GetFolderSizes(){
>> $fsTable.clear()
>> $snServername = $snServerNameDrop.SelectedItem.ToString()
>> write-host $dgDataGrid.CurrentCell.RowIndex
>> $siSIDToSearch = get-user 
>> $msTable.DefaultView[$dgDataGrid.CurrentCell.RowIndex][0]
>> write-host $siSIDToSearch.SamAccountName.ToString()
>> Get-MailboxFolderStatistics $siSIDToSearch.SamAccountName.ToString() | 
>> ForEach-Object{
>> $ficount = 0
>> $fisize = 0
>> $fsisize = 0
>> $fscount = 0
>> $fname = $_.Name
>> if ($_.FolderSize -ne $null){$fsisize = 
>> [math]::round(($_.FolderSize/1mb),2)}
>> if ($_.ItemsInFolder -ne $null){$ficount = $_.ItemsInFolder}
>> if ($_.ItemsInFolderAndSubfolders -ne $null){$fscount = 
>> $_.ItemsInFolderAndSubfolders}
>> if ($_.FolderAndSubfolderSize -ne $null){$fsisize = 
>> [math]::round(($_.FolderAndSubfolderSize/1mb),2)}
>> $fsTable.Rows.add($fname,$ficount,$fsisize,$fscount,$fsisize)
>> }
>> $dgDataGrid1.DataSource = $fsTable
>> }
>>
>> function ExportMBcsv{
>>
>> $exFileName = new-object System.Windows.Forms.saveFileDialog
>> $exFileName.DefaultExt = "csv"
>> $exFileName.Filter = "csv files (*.csv)|*.csv"
>> $exFileName.InitialDirectory = "c:\temp"
>> $exFileName.ShowDialog()
>> if ($exFileName.FileName -ne ""){
>> $logfile = new-object IO.StreamWriter($exFileName.FileName,$true)
>> $logfile.WriteLine("UserName,# Items,MB Size(MB),DelItems(KB)")
>> foreach($row in $msTable.Rows){
>> $logfile.WriteLine("`"" + $row[0].ToString() + "`"," + 
>> $row[1].ToString() + "," + $row[2].ToString() + "," + $row[3].ToString())
>> }
>> $logfile.Close()
>> }
>> }
>>
>> function ExportFScsv{
>>
>> $exFileName = new-object System.Windows.Forms.saveFileDialog
>> $exFileName.DefaultExt = "csv"
>> $exFileName.Filter = "csv files (*.csv)|*.csv"
>> $exFileName.InitialDirectory = "c:\temp"
>> $exFileName.ShowDialog()
>> if ($exFileName.FileName -ne ""){
>> $logfile = new-object IO.StreamWriter($exFileName.FileName,$true)
>> $logfile.WriteLine("DisplayName,# Items,Folder Size(MB),# Items + 
>> Sub,Folder Size + Sub(MB)")
>> foreach($row in $fsTable.Rows){
>> $logfile.WriteLine("`"" + $row[0].ToString() + "`"," + 
>> $row[1].ToString() + "," + $row[2].ToString() + "," + 
>> $row[3].ToString() + "," + $row[4].ToString())
>> }
>> $logfile.Close()
>> }
>> }
>>
>> $usrquotas = @{ }
>> $mstoresquotas = @{ }
>> $form = new-object System.Windows.Forms.form
>> $global:LastFolder = ""
>> # Add DataTable
>>
>> $Dataset = New-Object System.Data.DataSet
>> $fsTable = New-Object System.Data.DataTable
>> $fsTable.TableName = "Folder Sizes"
>> $fsTable.Columns.Add("DisplayName")
>> $fsTable.Columns.Add("# Items",[int64])
>> $fsTable.Columns.Add("Folder Size(MB)",[int64])
>> $fsTable.Columns.Add("# Items + Sub",[int64])
>> $fsTable.Columns.Add("Folder Size + Sub(MB)",[int64])
>> $Dataset.tables.add($fsTable)
>>
>> $msTable = New-Object System.Data.DataTable
>> $msTable.TableName = "Mailbox Sizes"
>> $msTable.Columns.Add("UserName")
>> $msTable.Columns.Add("# Items",[int64])
>> $msTable.Columns.Add("MB Size(MB)",[int64])
>> $msTable.Columns.Add("DelItems(MB)",[int64])
>> $msTable.Columns.Add("Quota Used",[int64])
>> $Dataset.tables.add($msTable)
>>
>> # Add Server DropLable
>> $snServerNamelableBox = new-object System.Windows.Forms.Label
>> $snServerNamelableBox.Location = new-object System.Drawing.Size(10,20)
>> $snServerNamelableBox.size = new-object System.Drawing.Size(80,20)
>> $snServerNamelableBox.Text = "ServerName"
>> $form.Controls.Add($snServerNamelableBox)
>>
>> # Add Server Drop Down
>> $snServerNameDrop = new-object System.Windows.Forms.ComboBox
>> $snServerNameDrop.Location = new-object System.Drawing.Size(90,20)
>> $snServerNameDrop.Size = new-object System.Drawing.Size(100,30)
>> get-mailboxserver | ForEach-Object{$snServerNameDrop.Items.Add($_.Name)}
>> $snServerNameDrop.Add_SelectedValueChanged({getMailboxSizes})
>> $form.Controls.Add($snServerNameDrop)
>>
>> # Add Mailbox Type DropLable
>> $mtTypeDroplableBox = new-object System.Windows.Forms.Label
>> $mtTypeDroplableBox.Location = new-object System.Drawing.Size(200,20)
>> $mtTypeDroplableBox.size = new-object System.Drawing.Size(80,20)
>> $mtTypeDroplableBox.Text = "MailboxType"
>> $form.Controls.Add($mtTypeDroplableBox)
>>
>> # Add Mailbox Type Drop Down
>> $mtTypeDrop = new-object System.Windows.Forms.ComboBox
>> $mtTypeDrop.Location = new-object System.Drawing.Size(290,20)
>> $mtTypeDrop.Size = new-object System.Drawing.Size(100,30)
>> $mtTypeDrop.Items.Add("Disconnected")
>> $mtTypeDrop.Items.Add("Connected")
>> $mtTypeDrop.Add_SelectedValueChanged({if 
>> ($snServerNameDrop.SelectedItem -ne $null){getMailboxSizes}})
>> $form.Controls.Add($mtTypeDrop)
>>
>> # Add Export MB Button
>>
>> $exButton1 = new-object System.Windows.Forms.Button
>> $exButton1.Location = new-object System.Drawing.Size(10,560)
>> $exButton1.Size = new-object System.Drawing.Size(125,20)
>> $exButton1.Text = "Export Mailbox Grid"
>> $exButton1.Add_Click({ExportMBcsv})
>> $form.Controls.Add($exButton1)
>>
>> # Add Export FG Button
>>
>> $exButton2 = new-object System.Windows.Forms.Button
>> $exButton2.Location = new-object System.Drawing.Size(550,560)
>> $exButton2.Size = new-object System.Drawing.Size(135,20)
>> $exButton2.Text = "Export FolderSize Grid"
>> $exButton2.Add_Click({ExportFScsv})
>> $form.Controls.Add($exButton2)
>>
>> # Add DataGrid View
>>
>> $dgDataGrid = new-object System.windows.forms.DataGridView
>> $dgDataGrid.Location = new-object System.Drawing.Size(10,50)
>> $dgDataGrid.size = new-object System.Drawing.Size(530,500)
>> $dgDataGrid.AutoSizeRowsMode = "AllHeaders"
>> $form.Controls.Add($dgDataGrid)
>>
>> $dgDataGrid1 = new-object System.windows.forms.DataGridView
>> $dgDataGrid1.Location = new-object System.Drawing.Size(550,50)
>> $dgDataGrid1.size = new-object System.Drawing.Size(450,500)
>> $dgDataGrid1.AutoSizeRowsMode = "AllHeaders"
>> $form.Controls.Add($dgDataGrid1)
>>
>> # folder Size Button
>>
>> $fsizeButton = new-object System.Windows.Forms.Button
>> $fsizeButton.Location = new-object System.Drawing.Size(500,19)
>> $fsizeButton.Size = new-object System.Drawing.Size(120,23)
>> $fsizeButton.Text = "Get Folder Size"
>> $fsizeButton.visible = $True
>> $fsizeButton.Add_Click({GetFolderSizes})
>> $form.Controls.Add($fsizeButton)
>>
>>
>>
>> $form.Text = "Exchange 2007 Mailbox Size Form"
>> $form.size = new-object System.Drawing.Size(1000,620)
>> $form.autoscroll = $true
>> $form.topmost = $true
>> $form.Add_Shown({$form.Activate()})
>> $form.ShowDialog() 
>
date: Wed, 21 May 2008 10:06:13 -0500   author:   kelly goff

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us