Rapture in Everything

Manipulate MSMQ with PowerShell


I´ve recently published an open source MSMQ component for the SQL Server Integration Services. While working on its implementation (and other, related things), I’ve created some PowerShell utilities for queue manipulation. Now I’m consolidating them and putting them here, too. I’ts just a single ps1 file.


A valid question. After all, there already are PS cmdlets that do the same thing, and more.

An advantage of this script is that while you have to install the MSMQ Cmdlets module, you only need to download the queue script and run it. (It doesn’t depend on those cmdlets, but uses the .NET System.Messaging.MessageQueue class internally.)

It’s also a lot simpler and isn’t meant as a replacement for those cmdlets – this is just a script that enables you to quickly do tasks you’re probably going to be doing a lot, while trying to get your data flowing.

What does it do?

You will always want to run it like this:

queue <command> <queue name>

These are the available commands:

When the preconditions of an action aren’t strictly met (e.g. you’re trying to create a queue that exists, delete one that doesn’t, purging an empty queue, etc), no error will be thrown. If you want to see exactly what the script is doing, run it with the standard -verbose parameter.

There are usage examples right in the script – either read them there, or run help queue -examples.