Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get more than 97 rows out of WMI?

Tags:

vbscript

wmi

I have the following .VBS script, which works, but it only returns the top ±100(97) rows of data. How do I get the full list?

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_MSMQ_MSMQQueue",,48)
For Each objItem in colItems
    Wscript.Echo objItem.Name & " - " & objItem.MessagesinQueue
Next
like image 975
My Other Me Avatar asked Dec 19 '11 10:12

My Other Me


2 Answers

With a little googling I found a post by Yoel Arnon (web search says he's a guru on MSMQ), The MSMQ WMI Provider. In it he states that the MSMQ performance counters have a limitation that they only provide "the first 97 queues (local and outgoing queues) in your computer".

In the same post he provides a link to a new WMI provider he developed to overcome that limitation plus some others, as well as an email address for contact info. The post is three years old but the file is still available for download.

like image 138
Daryn Avatar answered Sep 22 '22 18:09

Daryn


To accomplish what you are looking for, and the answer by Daryn about MS specifically cancelling after 97 entries, I would adjust your process into say... 2 or 3 queries...

Your query is looking for

Select * from Win32_PerfFormattedData_MSMQ_MSMQQueue

Look for some pattern of the data that is already filling your first 97 that would be less than the 97... such as

Select * from Win32_PerfFormattedData_MSMQ_MSMQQueue 
     where SomeColumn = 'Some Common Value'

then do a SECOND pass with

Select * from Win32_PerfFormattedData_MSMQ_MSMQQueue 
     where NOT SomeColumn = 'Some Common Value'

This would help you get to a max of 194 entries... Find yet another "Common" element and break it into 3 passes respectively and each could be put into its own FOR/EACH loop to populate your echo list back to the user.

like image 41
DRapp Avatar answered Sep 23 '22 18:09

DRapp