Part 4 of a series of posts on working with IBM WebSphere MQ from Windows PowerShell

This week, I’ve been demonstrating how to use Windows PowerShell to administer WebSphere MQ systems, using the support provided by SupportPac MO74.

On Tuesday, I discussed creating new WMQ objects from PowerShell. Today, I want to talk about how to modify existing WebSphere MQ objects.

The commands all start with Set-WMQ:

PS C:\> Get-Command Set-WMQ*

  CommandType     Name
  -----------     ----
  Cmdlet          Set-WMQChannel
  Cmdlet          Set-WMQListener
  Cmdlet          Set-WMQNamelist
  Cmdlet          Set-WMQProcess
  Cmdlet          Set-WMQQueue
  Cmdlet          Set-WMQQueueManager
  Cmdlet          Set-WMQService

PS C:\>  

The Set-WMQ commands will attempt to modify any object passed to it down the pipeline. Properties are specified in the same way as with the New-WMQ commands as described on Tuesday.

For example, to modify the description of the queue MYDEMOQ on MYQMGR to “modified description”, you can type:

PS C:\> Get-WMQQueue MYDEMOQ MYQMGR | Set-WMQQueue -Description "modified description"

To modify multiple objects, pass multiple objects down the pipeline to the Set-WMQ command:

PS C:\> Get-WMQQueue | Where { $_.Name -notmatch "SYSTEM.*" } | Set-WMQQueue -MaximumDepth 10


This sets the maximum depth of all non-system queues (all queues with names that don’t begin with “SYSTEM.”) on all local queue managers, to 10 messages.

Similarly, the following command sets the description of all put-inhibited queues on TESTQMGR to “i am a put inhibited queue”.

PS C:\> Get-WMQQueue -QmgrName TESTQMGR | Where { $_.InhibitPut -eq "Inhibited" } | Set-WMQQueue -Description "i am a put inhibited queue"

What’s next?

This is starting to demonstrate the benefits of using PowerShell over traditional runmqsc scripting. Refer to yesterday’s post to see how you can make queries identify objects which meet complex criteria. Being able to modify objects which are a result of these queries is very powerful. In tomorrow’s post, I’ll look at some advanced uses of PowerShell for WebSphere MQ.

If you can’t wait till then, or want more examples, there is a “Cookbook for ‘PowerShell for WebSphere MQ'” – which contains dozens of worked examples for using PowerShell with your queue managers. Download the MO74 zip file and you will find the powershellcookbook.pdf included.

What do you think?

What do you think about this? Feedback on the SupportPac or the potential of PowerShell administration for WebSphere MQ, is very welcome. If you have any questions, I’d also be happy to try and answer them.