Comments : 0

Mailbox Report Script for Exchange Server

Category : Exchange Server

One of the tasks that every Exchange Server administrator faces as part of their daily or weekly maintenance is getting the mailbox size report of the Exchange Server. The PowerShell commands do help in getting the relevant data, but doing this rudementary task manually everytime is painstaking. Here is a small script which can used to generate the mailbox statistics report and then automatically email the same as an attachment. To automate this further, one can create a Scheduled Task in Task Manager so that it runs at the specified interval.

###Exchange Mailbox Statistics Script
###Modify Variable Data
$FromAddress = "noreply@domain.com"
$ToAddress = "administrator@domain.com"
$MessageSubject = "Exchange Mailbox Report"
$MessageBody = "Mailbox Statistics of Exchange Server is attached with this email."
$SendingServer = "exchangeserver.yourdomain.com"
####DO NOT EDIT BELOW THIS LINE
###Get Stats and Prepare Text File
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}}, ItemCount, StorageLimitStatus > mailboxes.txt
###Create Email and Attach Report
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress,
$MessageSubject, $MessageBody
$Attachment = New-Object Net.Mail.Attachment("mailboxes.txt")
$SMTPMessage.Attachments.Add($Attachment)
###Send Email
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)

Hope the above script helps and saves the administration time.

Comments : 0

TMG Managed Control Service, Exchange Edge and FPE

Category : Exchange Server, ISA Server and Forefront

Recently I encountered TMG Managed Control Service crashing at a client site where they have been using TMG as a back-end firewall. The same server was also being used as an Exchange 2007 Edge server also running Forefront Protection for Exchange 2010. All server roles were patched with the latest updates and rollups. The connectivity between the Edge and the Hub was implemented successfully and also verified using Test-EdgeSync. TMG also showed Edge and Hub connectivity. Everything looked healthy but the IT administrator was receiving email alerts with the following:

“Email Policy could not be applied. Value does not fall within the expected range.”

Went to the services MMC and tried to start the TMG Managed Control Service manually. The service failed to start. Upon checking the event logs, I found that the Application Log showed:

 - Event ID 31309: E-mail policy configuration settings cannot be applied.
- Event ID 31308: The Forefront TMG Managed Control service failed to initialize. Error information: The type initializer for ‘Microsoft.Isa.Smtp.ExchangeRunspace’ threw an exception.
- Event ID 31307: The Forefront TMG Managed Control service was stopped gracefully.

and the System Log showed Event ID 7023: The Microsoft Forefront TMG Managed Control service terminated with the following error: %%-2146233036

The next step was to check the Edge and Hub communication and as expected it should that the sync was not working. TMG console showed everything configured and all Anti-Spam rules enabled. I had no choice but to pick up the phone and shake someone up in Microsoft technical team for an answer. Sadly, no clue from there too, but one thing that came up in the discussion was to clear all Anti-Spam settings and then give this a reboot. Long process, but to cut things short, here is the solution that worked.

For those facing this issue, open up Exchange Shell on the Edge server and run:

Get-IpBlockListEntry

This should come up with a list of entries. The next step is to remove these. Run the following command:

Get-IpBlockListEntry | RemoveIpBlockListEntry

To clear all entries, answer with an “A”. Started the service this time and the TMG Managed Control Service started successfully.

Though running the command of Get-IpBlockListEntry after 10-15 minutes showed that the list was building up once again and after 30 minutes the TMG managed Control Service crashed once again.

The only workaround that I could implement to fix this permanently was to disable the Sender Reputation Service in TMG. It has been more than a week now and the TMG Managed Control Service has not crashed once.

Comments : 6

Backup Exchange Server 2007 on Windows 2008 using NTBackup

Category : Exchange Server, Microsoft Windows Server

All those System Administrators running their Exchange Server 2007 on a Windows 2003 (64-bit) server have the previlage to get access to the traditional NTBackup utility to backup their exchange stores. But those who are running their Exchange Server 2007 on Windows 2008 (64-bit) must have faced the dilema of which tool to use to backup their mail stores. This is because Windows Server Backup in Windows Server 2008 no longer supports Exchange-aware backups or restores. In order to back up and restore Exchange Server 2007 Service Pack 1 (SP1) on Windows Server 2008, you must use an Exchange-aware application that supports the Volume Shadow Copy Service (VSS) writer for Exchange 2007, such as Microsoft System Center Data Protection Manager, a third-party Exchange-aware VSS-based application, or a third-party Exchange-aware application that uses the streaming backup APIs locally on the Exchange server to make a backup locally on the Exchange server.

What does all this mean? Nothing but shelling out extra $$$ to invest in a backup solution unless you are interested in a very simple backup solution to assure that the logs get truncated and you have backup copies which you can restore. Here is a basic hack which can help one save a couple of $$$.

Step #1

Get access to a Windows 2003 R2 Server which is running a 64-bit OS. Assuming that you are not running your production Exchange Server 2007 in 32-bit environment, we require the 64-bit version library files. If you do not have a one handy, you can get the source files and then expand the DLL’s or install one in a virtual environment.

Step #2

Copy the ntbackup.exe, ntmsapi.dll, and vssapi.dll files from C:\windows\system32 into a new folder on your Exchange Server 2007 running on Windows 2008. I created a folder called NTBackup under Program Files and placed them there.

NT Backup Exchange 2007

NT Backup Exchange 2007

Step # 3

Right click Ntbackup.exe and choose “Run as administrator”.

Your should see the Exchange Server Information Store as part of your backup wizard.

Select the Information Stores that you want to backup. Choose the Backup media or filename and the path where you want to store your backups. Once you have finished the configuration, click on Start Backup and the exchange store backups should start.

Once the backup is complete, you should see all the transaction logs getting truncated (hope circular logging is not enabled) and also the mail store would be stamped with the Last Full Backup date and time stamp.

One thing to note though: you cannot back up a storage group in a Standby Continuous Replication (SCR) environment. Backups of storage group copies are available for Local Continuous Replication (LCR) or Cluster Continuous Replication only.