Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - [MSMQ]Shell for basic opeartions with MSMQ ?

Reply
 
Old 09-17-2007   #1 (permalink)
Oriane


 
 

[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 SpecsSystem Spec
Old 09-18-2007   #2 (permalink)
Thomas Lee


 
 

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 SpecsSystem Spec
Old 09-18-2007   #3 (permalink)
forestial


 
 

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)
.... and so on. Hope this helps.

"Oriane" wrote:
Quote:

> Hi there,
>
> is it posible to use PowerShell to read/send message in a private MSMQ queue
> ?
>
> Oriane
>
>
My System SpecsSystem Spec
Old 09-19-2007   #4 (permalink)
forestial


 
 

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 SpecsSystem Spec
Old 09-25-2007   #5 (permalink)
Oriane


 
 

Re: [MSMQ]Shell for basic opeartions with MSMQ ?

Thanks a lot !
My System SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46