![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | [MSMQ]Shell for basic opeartions with MSMQ ? Hi there, is it posible to use PowerShell to read/send message in a private MSMQ queue ? Oriane |
My System Specs![]() |
| | #2 (permalink) |
| | Re: [MSMQ]Shell for basic opeartions with MSMQ ? In message <DAAAA957-6CAA-4A5D-933C-0C334AB2334E@xxxxxx>, Oriane <oriane@xxxxxx> writes Quote: >Hi there, > >is it posible to use PowerShell to read/send message in a private MSMQ >queue ? There are no native cmdlets or providers to read/write to the MSMQ, so in terms of out of the box features, the answer is no. I don't know the implementation of MSMQ well enough, but it seems reasonable to assume someone could write a cmdlet to add stuff to MSMQ. -- Thomas Lee doctordns@xxxxxx MVP - Admin Frameworks and Security |
My System Specs![]() |
| | #3 (permalink) |
| | RE: [MSMQ]Shell for basic opeartions with MSMQ ? There is no specific support in Powershell for MSMQ programming. However since you can call essentially any .NET api from Powershell it may be possible to get this to work if you are familiar with the System.Messaging namespace. I have not been able to get MSMQ installed correctly on the machine I am using here, so take the following as hints rather than specific instructions.... Quote: > [Reflection.Assembly]::LoadWithPartialName("System.Messaging") Quote: > $queue = [System.Messaging.MessageQueue]::Create(".\private$\MyQueue") Quote: > $message = new-object System.Messaging.Message Quote: > $queue.Send($Message) "Oriane" wrote: Quote: > Hi there, > > is it posible to use PowerShell to read/send message in a private MSMQ queue > ? > > Oriane > > |
My System Specs![]() |
| | #4 (permalink) |
| | RE: [MSMQ]Shell for basic opeartions with MSMQ ? Well, this piqued my interest so I installed MSMQ properly and got some basic things to work from Powershell. Here are some notes and sample code. # must load the Messaging assembly, it's not there by default [Reflection.Assembly]::LoadWithPartialName("System.Messaging") # create a new queue... $qnew = [System.Messaging.MessageQueue]::Create(".\private$\queue1") # ... or access an existing queue $q1 = new-object System.Messaging.MessageQueue ".\private$\queue1" # Create a message $msg = new-object System.Messaging.Message "Into the Mystic" $msg.Label = "A label" # Send the message to the queue $q1.Send($msg) # Create and send as many more messages as needed... # ... now to read some of them back again # Messages in our queue will hold bodies of type string. Set up an array of type # names for the formatter (can there be more than one?). $q1.Formatter.TargetTypeNames = ,"System.String" # tell the queue we'd like to see some additional properties on # messages we retrieve $q1.MessageReadPropertyFilter.ArrivedTime = $true $q1.MessageReadPropertyFilter.SentTime = $true # Peek at the first message in the queue $pkmsg = $q1.Peek() # look at its properties.. $pkmsg # Better have a timeout on peek and retrieve operations; if the queue # is empty they will block the powershell session otherwise $ts = new-object TimeSpan 30000000 # 3 seconds for example $pkmsg = $q1.Peek($ts) # Retreive and remove the first message in the queue $rmsg = $q1.Receive($ts) # look at its properties.. $rmsg.body Into the Mystic One quirk is that just typing $q1 causes it to list the properties of (what appears to be) every message in the queue, rather than the properties of the queue itself. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: [MSMQ]Shell for basic opeartions with MSMQ ? Thanks a lot ! |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| MSMQ Monitoring script | VB Script | |||
| secure msmq | .NET General | |||
| Re: MSMQ Peek not working right | PowerShell | |||
| MSMQ Peek not working right | PowerShell | |||
| MSMQ Usage in PS | PowerShell | |||