Skip to content

Instantly share code, notes, and snippets.

@abix-
abix- / Check-Queues.ps1
Last active August 29, 2015 14:24
How can I monitor and purge large MSMQ queues?
#If the number of messages in a queue are above this value, the queue will be purged.
$threshold = 500000
#Logging configuration
$path = "G:\Jobs"
$logname = "msmq_monitor.log"
$rotation_threshold_mb = 10
function EmailResults($computername,$queuename,$messagecount) {
$global:smtpserver = "smtpserver.domain.local"
[cmdletbinding()]
Param (
[Parameter(Mandatory=$true)]$domain
)
#Import Active Directory module
Import-Module ActiveDirectory
#Initialize arrays to store results
$results = @()
$zoneresults = @()