I’ve just uploaded an update to the Start-MailGen.ps1 script, which is a free PowerShell script that you can use to generate email traffic within a test lab environment.

This new version has the following updates and improvements:

  • Updated to use Exchange Web Services Managed API 2.0
  • Tested on Exchange Server 2010 and 2013
  • Fixes bug where last mailbox in alphabetical order would never be picked as a sender or recipient
  • Added code for Exchange snap-in to load to simplify running script as a scheduled task
  • Distribution groups are now included as possible recipients of emails
  • Recipient list is refreshed on every loop so that newly created recipients are included
  • Messages are now sent to a random number of recipients between 1 and 5 instead of only single recipients (you can increase this if you like)
  • Messages will now randomly include a file attachment chosen from the Attachments folder. This will happen about 30% of the time. You can add your own attachments to that folder if you want more variety as well.

Usage instructions and download link are here.

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. zDonJimmy

    Hi All,

    some notes that make the script work for me with no issues
    * If you are going to use mail.yourdomain.com in the $service.Url
    – You should install “EWS Managed API” on all exchange servers.
    – Make sure that the installed certificate matches the same name as well.
    * If you are going to point to a dedicated server, just make sure that the EWS package is installed there.
    * Regarding the parameter of $mail.SendAndSaveCopy() – i added number 1 between the Parentheses

  2. Neco

    Hi, does this work with Office 365?

  3. Cody DeVecht

    Paul – I am using this script in a lab environment to do some testing with Cumulative Updates and it has been working flawlessly from SP1 to CU12, CU12 to CU15, and CU15 to CU19.

    This morning I updated from CU19 to CU20 and now when I run the script again it throws an exception during the Preparing EWS stage. This line in particular: $service.AutodiscoverUrl($user.Properties.mail). It also references line 367, so I tried to change this to “Exchange2013” and “Exchange2013_SP1” but receive the same exception message either way.

    The exception states that the AutoDiscover service could not be located. I am wondering if something changed from CU19 to CU20 that might have caused this unexpected issue? I would like to ensure that this is an issue with the script itself and not with the upgrade process prior to performing the same steps in the production exchange environment.

    Love your blog, thanks for all the help you have unknowingly provided to me over the years!

  4. RB

    Hi Paul,

    – can the script be used to generate mail load onto the exchange servers?
    – How many emails can be sent out a a client generator machine (i.e. dual core 1.5Ghz, 8 GB)?
    – Is there a way to coordinate the testing to launch emails from multiple remote servers?
    – How many sender email accounts should I have in exchange to send ie. 4000 emails per hour?
    – Does the script replicate the number of multiple tcp connections that are normally opened by outlook client?

    thanks

    1. Avatar photo

      1) No. This is not a load testing tool. Microsoft already provides tools for that purpose.
      2) No idea.
      3) No. Feel free to modify the code to suit your requirements.
      4) No idea. Try it and see for yourself? You can always run multiple instances of the script if a single instance isn’t sending fast enough.
      5) No, it’s not a load testing tool.

  5. Arjan Mensch

    Thanks Paul!
    Using this to test our first attempt at a hosted exchange 2013 setup.

    Cheers

Leave a Reply