ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General Discussion » Using powershell for MQ scripting

Post new topic  Reply to topic
 Using powershell for MQ scripting « View previous topic :: View next topic » 
Author Message
ankurlodhi
PostPosted: Wed Jan 15, 2020 4:45 am    Post subject: Using powershell for MQ scripting Reply with quote

Master

Joined: 19 Oct 2010
Posts: 266

I am trying to fetch the value of Queue Manager name from the below output using Powershell,


QMNAME(TEST) STATUS(Running)
QMNAME(CLxxxxxxxxx) STATUS(Running)
QMNAME(QMxxxxxxxxxxxxx) STATUS(Running)
QMNAME(QMxxxxxxxxxxxxxx) STATUS(Running)
QMNAME(xxxxxxxxxxxxxxx) STATUS(Running)
QMNAME(xxxxxxxxxxxx) STATUS(Running)

i am basically trying to convert the below script to Batch but can't find a replacement for CUT and AWK.

NOW=`date +"%Y%m%d"`
rootdir="Directory"
FILE_LOC="Directory"
rm $FILE_LOC/*.csv
QMGR=`dspmq |grep "Running"| awk '{print $1}' | cut -f2 -d "(" | cut -f1 -d ")" `
QMSTATUS=`dspmq | awk '{print $2}' | cut -f2 -d "(" | cut -f1 -d ")"`

for e in $QMGR
do
echo "Application Connected to QMGR : $e"
echo "DISPLAY QSTATUS(*) TYPE(HANDLE) OPENTYPE ( ALL ) CONNAME" | runmqsc $e > $FILE_LOC/$e.csv
echo "DISPLAY QSTATUS(*) TYPE(HANDLE) OPENTYPE ( ALL ) Where( CONNAME NE ' ') CONNAME CHANNEL" | runmqsc $e > $FILE_LOC/$e.mqsc
echo "QMANAGER:$e" > $FILE_LOC/$e.csv
port=`echo "dis LISTENER($e.LSTR) PORT"|runmqsc $e|grep PORT|tr -s ' ' '|'|tail -1|cut -d '|' -f3|tr -s '(' '|'|tr -s ')' '|'|cut -d '|' -f2`
echo "PORTNUMBER:$port" >> $FILE_LOC/$e.csv
echo "DISPLAY QSTATUS(*) TYPE(HANDLE) OPENTYPE ( ALL ) Where( CONNAME NE ' ') CONNAME CHANNEL" | runmqsc $e|grep -v MQMON|grep -v SYSTEM|grep -v UT|grep -v AMQ8450|grep -v DISPLAY|grep -v Copyright|grep -v Starting|grep -v MQSC|grep -v commands|grep -v valid|tr -s " " "\n" >>$FILE_LOC/$e.csv



chmod 757 $FILE_LOC/$e.csv
done
Back to top
View user's profile Send private message
exerk
PostPosted: Wed Jan 15, 2020 6:59 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

Why not check the Registry for names and statuses?

For example:

Code:
# List the Queue Managers
$key_name = Get-ItemProperty hklm:\SOFTWARE\Wow6432Node\IBM\MQSeries\CurrentVersion\Configuration\QueueManager\* "Name"
# Check their status
ForEach ($i in $key_name) {
   $qmgr_name = $i.PSObject.Properties["Name"].Value
   $key_status = Get-ItemProperty hklm:software\Wow6432Node\IBM\MQSeries\CurrentVersion\Status\QueueManager\$qmgr_name\QueueManagerStatus "CurrentStatus"
   $qmgr_status = $key_status.PSObject.Properties["CurrentStatus"].Value
}


That's old code by the way, I haven't rechecked it against a current installation.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » Using powershell for MQ scripting
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.