Solved

PowerShell script that displays Exchange 2003 mail store deleted items disk consumption

Posted on 2010-11-11
7
949 Views
Last Modified: 2012-06-27
I would like to execute a Powershell script that would display the disk space consumed its mailboxes deleted items.  Currently my Exchange environment is 2003; therefore, I am unable run to utilize the commands available to Exchange 2007.
0
Comment
Question by:jahhan
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:Gitcho
ID: 34117837
#the exchange server name
$exchangeServer = "SERVER01"
#get all mailboxes
$2003server = Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $exchangeServer
#strip system mailboxes
$2003server = ($2003server | ? {$_.DisplayName -notlike "SystemMailbox*"})
#calculate total size of deleted items
$deletedTotal = ($2003server | Measure-Object DeletedMessageSizeExtended -Sum).Sum
#total size in MB
([math]::round(($deletedTotal/1MB), 2))
0
 

Author Comment

by:jahhan
ID: 34122342
This is what I need, however, is it possible to list the server values individually?  So far, when i run the script, it provides one value.
0
 
LVL 5

Expert Comment

by:Gitcho
ID: 34123112
Not sure what you mean ... this script is only querying one server - so there is only 1 server value.   If you want to output the server name along with the total deleted items space, just change the last line to:

Write-Host $exchangeServer " has a total of " ([math]::round(($deletedTotal/1MB), 2)) "MB of delete items"

Open in new window


If you're asking to output the value of each USER's delete item total, then add this line:

$2003server | % { Write-Host ($_.MailboxDisplayName)":"([math]::round(($_.size/1KB), 2))  }

Open in new window


0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:jahhan
ID: 34123471
I have multiple servers listed in the $exchangeservers line, but when I run the script only one value is displayed, and this value seem as if its the total off all the servers values.
0
 
LVL 5

Accepted Solution

by:
Gitcho earned 500 total points
ID: 34123690
OK.  try this :

#load server names from file
$exchangeServer = gc "c:\files\list_of_servers_to_check.txt" #one server name on each line
#process each server
Foreach ($server in $exchangeServer) { 
	#get all mailboxes 
	$2003server = Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $server
	#strip system mailboxes
	$2003server = ($2003server | ? {$_.DisplayName -notlike "SystemMailbox*"})
	#calculate total size of deleted items
	$deletedTotal = ($2003server | Measure-Object DeletedMessageSizeExtended -Sum).Sum
	#total size in MB
	Write-Host $server " has a total of " ([math]::round(($deletedTotal/1MB), 2)) "MB of deleted items"
}

Open in new window

0
 

Author Comment

by:jahhan
ID: 34124013
Thanks for the script, is it possible to remove the write-host line and add script that will display the output on the results screen?
0
 
LVL 5

Expert Comment

by:Gitcho
ID: 34125706
The write-host line *does* display the output on the screen.  If you don't want to display anything to the screen just delete that last line.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
how to add IIS SMTP to handle application/Scanner relays into office 365.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now