Showing posts with label Powershell. Show all posts
Showing posts with label Powershell. Show all posts

Monday, December 17, 2012

NSB PowerShell Support in v3.3

Looks like this is the answer to my request for granular control over infrastructure installation. This works for me as PowerShell is our common denominator for our developers and admins. After getting through the new MSI installer, you will see a new short cut to a prompt.

I'm runing Windows 7 Enterprise and you will get an error OOTB

To get rid of this error you have to install PowerShell v3.  I won't show examples of all the commands available, but we do now have full control over what is installed.  Here is a listing of what is available:

Get-Message
Get-NServiceBusVersion
Install-Dtc
Install-License
Install-Msmq
Install-PerformanceCounters
Install-RavenDB

I think all of these are pretty self explanatory.  The great news is this takes care of allowing you to install only what you need instead of everything in the kitchen sink.

Monday, March 21, 2011

ReturnToSourceQueue PowerShell Script: Updated

UPDATE: I've added transaction support to the script.  Previous to this you would have lost a message if something had gone wrong.  PS does not support TransactionScope, so we had to use MessageQueueTransaction.

The ReturnToSourceQueue.exe tool that comes with NSB presented a challenge to us when we tried to deploy it on all our app servers.  We needed to schedule an on-demand job to run the tool by our Operations group.  Since the agent we use goes on each machine and is not cluster aware, this presented an issue.  Our resolution was to replicate the same functionality in PS with a bit of a twist.  We added the ability to hit a remote queue.  The script was done by one of our developers Brandon Moriarty and I've posted it to GitHub for everyone to enjoy!  Big thanks to Brandon for whipping this one up.  Don't forget I have a few other PS scripts in there to do some quick and dirty things with MSMQ.

Friday, March 18, 2011

ReturnToSourceQueue PowerShell Script

The ReturnToSourceQueue.exe tool that comes with NSB presented a challenge to us when we tried to deploy it on all our app servers.  We needed to schedule an on-demand job to run the tool by our Operations group.  Since the agent we use goes on each machine and is not cluster aware, this presented an issue.  Our resolution was to replicate the same functionality in PS with a bit of a twist.  We added the ability to hit a remote queue.  The script was done by one of our developers Brandon Moriarty and I've posted it to GitHub for everyone to enjoy!  Big thanks to Brandon for whipping this one up.  Don't forget I have a few other PS scripts in there to do some quick and dirty things with MSMQ.

Thursday, November 4, 2010

Powershell: Reading Messages from MSMQ

I'm throwing this out there since I couldn't find anything good online. We have admins that need to quickly look at messages in queues and the built-in tooling just isn't pretty to look at. Slap this PS code into a script file and you should be ready to rock!

param([string]$qname)

if ( [System.String]::IsNullOrEmpty($qname) )
{
    write-host "You must provide a queue name"
    exit
}

[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | out-null

$q = new-object System.Messaging.MessageQueue($qname)

$msgs = $q.GetAllMessages()

foreach ( $msg in $msgs )
{
    $msg.BodyStream.Position = 0
    $sr = new-object System.IO.StreamReader( $msg.BodyStream )
    $sr.ReadToEnd()
    $input = read-host -prompt "Enter n for the next message, q to quit"
    
    if ( $input -eq "q" )
    {
        exit
    }
}