Powershell Script to create an MSMQ

Powershell Script to create an MSMQ

Rate This
  • Comments 7

Here is a script to quickly create and delete queues. This was based out of this post.

Usage :
    CreateQueue.ps1 <-c,d> <queuename> <Y/N - Private> <user> <all:restricted Permission> [T:Transactional]
Attachment: CreateQueueu.ps1.txt
Leave a Comment
  • Please add 5 and 2 and type the answer here:
  • Post
  • Nice Sajay.

    It'll be good to check the existance of Queue before we create Queue:

       $qb = [System.Messaging.MessageQueue]::Exists($queuename)

       if($qb ! $null)

       {

           exit

       }

       $qb = [System.Messaging.MessageQueue]::Create($queuename, $transactional)

    ..

    ..

    ..

    I don't know if syntax is correct or not, but you can correct it and add to the script.

  • Here is the correct 1:

    $qb = [System.Messaging.MessageQueue]::Exists($queuename)

       if($qb -ne $null)

       {

           Write-Host "Alread have " $queuename "queue."

    exit

       }

       $qb = [System.Messaging.MessageQueue]::Create($queuename, $transactional)

    ..

    ..

    ..

  • Hi Sajay,

     I have written a simple script using PSCX 2.0 to create Private MSMQ in windows but I am not able to add a label to the same. Find the script below :

    New-MSMQueue -QueueName scheduler.q -Private

    Any help????

  • I used this to perform a server migration. I exported the queue list (several hundred queues) from Computer Management and then used a batch script to call this Powershell script to create that list of queues on the new box. You saved me hours of time and possible human error in the manually entry. Thanks!

  • Can you modify it so it will import queue names from a txt file?

  • This post is for others that need an example like myself :)

    -c = create

    myQ = the queue name

    n = not private

    everyone = the user or group name

    all = gives that user all permissions

    T = will make it transactional

    .\createqueue.ps1 -c csrtofe n everyone all T

  • Is there a way to set permissions for more than one group, and get more granular than just "all"

Page 1 of 1 (7 items)
Search