Archive for the ‘Exchange’ Category

I find myself again and again needing a constant flow of email messages to ease diagnosing message flow, so I wrote this little script to assist me. I mainly use this scripted function to test load balancing and perform latency checks but it has other benefits. One such recent example was where I needed to generating enough smtp traffic for a good sized network capture to diagnose a comms issue, this was easily achieved with the AttachmentSizeMB parameter.

I have also added comment-based help with a couple of examples, here’s the code:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin -ErrorAction SilentlyContinue
function Send-MailMessages {

Generate a constant flow of messages for diagnostic purposes.

This script is designed to assist in generating email messages for testing external message flow to and from your messaging infrastructure.
The ability to quickly send a batch of messages with an attachment on a schedule can help track flow issues or to simply be used to confirm mail routing.

Send-MailMessages -To -From -MessageCount 10 -SecondsDelay 10 -AttachmentSizeMB 1

Send 10 emails to every 10 seconds with a 1MB Attachment

Send-MailMessages -MessageCount 48 -SecondsDelay 1800

Send an email every 30 minutes for 24 hours.


File Name: Send-MailMessages.ps1
Author: jfrmilner
Requires: Powershell V2
Requires: Exchange Managemnent Shell (Only used to auto find the smtpServer)
Legal: This script is provided "AS IS" with no warranties or guarantees, and confers no rights. You may use, modify, reproduce, and distribute this script file in any way provided that you agree to give the original author credit.
Version: v1.0 - 2010 Aug 08 - First Version*
Version: v1.1 - 2012 April 26 - Fixed when only a single HT Server is available. Added check for existing file. Fixed attachment parameter to use varible.


param ( [Parameter(Mandatory=$false)] $To = "", [Parameter(Mandatory=$false)] $From = "", $AttachmentSizeMB=$null, $MessageCount=2, $SecondsDelay=10 )

$messageParameters = @{
 Body = $null | ConvertTo-Html -Body "<H2> Test Message, Please ignore </H2>" | Out-String
 From = $from
 To = $to
 SmtpServer = @(Get-TransportServer)[0].Name.ToString()
if ($AttachmentSizeMB) {

if ((Test-Path $Env:TMP\$($AttachmentSizeMB)mbfile.txt) -ne $true) {
 fsutil file createnew $Env:TMP\$($AttachmentSizeMB)mbfile.txt $($AttachmentSizeMB * 1MB)
$messageParameters.Add("attachment", "$Env:TMP\$($AttachmentSizeMB)mbfile.txt") }

1..$MessageCount | % { sleep -Seconds $secondsDelay ; Send-MailMessage @messageParameters -Subject ("Mailflow Test Email - " + (Get-Date).ToLongTimeString() + " Message " + $_ + " / $MessageCount") -BodyAsHtml }


This is an example of the what you can expect to see in the recipients mailbox:



Today I passed exam 70-236 which is the first exam I’ve taken since the shakeup. Having done my fair share of MCPs I was hoping that the MCTS series would be a little more practical but sadly this was not the case. In fact this exam was a test that seemed to focus on how well you know your Exchange PowerShell cmdlets, yes all 394 of them! Still a pass is a pass and with a score of 873/1000 I know I passed with room to spare.