Simulating email traffic in Exchange

I’ve lost count of how many times I’ve spun up an Exchange test environment only to stare at an idle queue, wondering how to simulate real-world traffic without actual users. If you’ve ever tried validating mail flow or stress-testing mailbox performance in a lab setup, you know the pain—no traffic means no insights.

This post walks through how I simulate email traffic using PowerShell. It’s a setup I’ve refined over time, mostly out of necessity. Not gonna lie, the first time I tried this, I was winging it with half-baked scripts and a few test mailboxes. These days, I’ve got a cleaner approach that works reliably across Exchange 2016, 2019, and even hybrid setups.

Why I Needed This

In production, Exchange servers are constantly buzzing—emails, calendar invites, attachments, you name it. But in a test lab? It’s usually just me, a few dummy users, and a lonely DAG. Without traffic, it’s tough to validate transport rules, mailbox quotas, or even basic performance metrics.

So I built a PowerShell script that mimics user behavior—sending emails from each mailbox to a distribution group at regular intervals. It’s not perfect, but it gets the job done.

How I Set It Up

Here’s the basic flow:

  • I created a PowerShell script (DummyEmail.ps1) that loops through all mailboxes and sends an email to a target group.
  • To avoid sending empty shells, I added a longtext.txt file with random content—think lorem ipsum meets tech blog ramblings. This gets injected into the email body.
  • I scheduled the script to run every 30 minutes using Windows Task Scheduler. You could use a cron job or even Azure Automation if you’re feeling fancy, but Task Scheduler works fine for local labs.

The script uses Send-MailMessage, grabs mailbox identities via Get-Mailbox, and cycles through them. I’ve tested this on a Hyper-V VM running Exchange 2019 CU13, with about 20 dummy users synced from a local AD.

Gotchas and Weird Behavior

One thing that tripped me up early on: Dynamic Distribution Groups. Most guides say they’re great for targeting users, but I found static groups more predictable in a test setup. DDGs sometimes resolve weirdly if your filters aren’t tight.

Also, Task Scheduler can be finicky with execution policies. I had to explicitly set -ExecutionPolicy Bypass in the action arguments, or the script would silently fail. The log was no help—just a generic “completed” status with no actual mail sent.

And yeah, ever spent an hour debugging a typo in a mailbox alias? Welcome to my world.

Lessons Learned

  • Always test the script manually before scheduling it. I’ve had cases where the scheduled task ran but didn’t send anything due to credential issues.
  • Add logging to your script. Even a simple Out-File trace helps when you’re trying to figure out why nothing’s moving.
  • Use verbose output during testing. Exchange cmdlets can be quiet when they fail.

Final Thoughts

This setup isn’t groundbreaking, but it’s saved me hours when validating mail flow, transport rules, and even spam filter behavior. If you’re running a lab and need to simulate realistic traffic, this PowerShell combo is a solid starting point.

I’ve shared a demo of the setup on YouTube, including how to configure Task Scheduler and inject the email body from a text file:

Ever tried simulating Exchange traffic a different way—maybe with third-party tools or load generators? I’d love to hear what worked (or didn’t) for you. Drop a comment or reach out if you’ve got a better trick up your sleeve.

PShivkumar

About the author: PShivkumar

With over 12 years of experience in IT and multiple certifications from Microsoft, our creator brings deep expertise in Exchange Server, Exchange Online, Windows OS, Teams, SharePoint, and virtualization. Scenario‑first guidance shaped by real incidents and recoveries Clear, actionable breakdowns of complex Microsoft ecosystems Focus on practicality, reliability, and repeatable workflows Whether supporting Microsoft technologies—server, client, or cloud—his work blends precision with creativity, making complex concepts accessible, practical, and engaging for professionals across the IT spectrum.

View all posts →

Comments

📝 Leave a Comment