Try {
    Write-Host -ForegroundColor yellow "`n--- Message Queues ---`n"

    [Reflection.Assembly]::LoadWithPArtialName("System.Messaging") | Out-Null
    $msmq = [System.Messaging.MessageQueue]

    function RemoveMessageQueue {
        $name = $args[0]
        $qname = ".\private$\$name"
        If (($msmq::Exists($qname))) {
            $qObject = $msmq::Delete($qname)
        }
    }

    # Sync message queues
    write-host "Removing Sync message queues..." -NoNewline
    RemoveMessageQueue "Sync-Token"
    write-host "done."

    # Controller message queues
    write-host "Removing Controller message queues..." -NoNewline
    RemoveMessageQueue "Controller"
    write-host "done."

    # Key/Card Watcher message queue
    write-host "Removing Key/Card Watcher message queue..." -NoNewline
    RemoveMessageQueue "Key-Card-Watcher"
    write-host "done."

    # Display message queues (to alert the Services when the Display App is running)
    write-host "Removing Display message queues..." -NoNewline
    RemoveMessageQueue "Display-SMS"
    RemoveMessageQueue "Display-SMS-Media-Status"
    write-host "done."
    
    # SMS message queues
    write-host "Removing SMS message queues.." -NoNewline
    RemoveMessageQueue "SMS-Display"
    RemoveMessageQueue "SMS-Controller"
    RemoveMessageQueue "SMS-Token"
    RemoveMessageQueue "Action-SMS"

    write-host "done."
}
Catch {
    throw $_.Exception.Message
}
