Powershell v1.0 and MSMQ
-
quinta-feira, 17 de setembro de 2009 16:56Hi All,
I'm trying to get the queue count for an MSMQ queue from Performance Monitor, but it doesn't seem to be letting me. I can see the queues when I go into Performance Monitor and add them to the graph with no problem. It's the accessing them with Powershell that's giving me grief.
It seems the MSMQ Queue Category is not visible to Powershell. When I run:
[System.Diagnostics.PerformanceCounterCategory]::GetCategories()
it doesn't show up in the list.?.
Anybody have any ideas. Thanks.
Gary
Todas as Respostas
-
quinta-feira, 17 de setembro de 2009 16:58Moderadorhave you tried via WMI?
Brandon Shell [MVP] -
quinta-feira, 17 de setembro de 2009 19:17Well... I'm trying to but I can figure out how?!? I'm trying
$myobj = get-wmiobject Win32_PerfFormattedData_msmq_MSMQQueue
but then I get nothing in $myobj. I'm not totally up to speed on Powershell, but I figured getting a little counter would be a good exercise. Seems like I chose the wrong counter (though it's only because we had a little overloaded queue the other day, so I wanted something that would monitor it and email me when it gets over a certain threshold). Can you give me a few pointers to get going on the right path.
-
quinta-feira, 17 de setembro de 2009 19:38Moderador
Well.. this is more of a performance counter issue then Powershell but I believe your running into the good old fashion "you can't really collect performance counters in a single instance."
Perf counters need to be collected over time.
You can do something like this
$Server = "myservername" $MSMQ = [System.Diagnostics.PerformanceCounterCategory]::GetCategories($Server) | ?{$_.Categoryname -eq "MSMQ Service"} $Counters = $MSMQ.GetCounters() foreach($counter in $counters) { $i = 0 $Counter | select CounterName,RawValue while($i -lt 5) { $i++ $Counter.NextValue() | out-null sleep 1 } $Counter | select CounterName,RawValue }
Brandon Shell [MVP]- Sugerido como Resposta BSonPoshMVP, Moderator quinta-feira, 17 de setembro de 2009 19:39
- Marcado como Resposta Marco ShawModerator sexta-feira, 18 de setembro de 2009 23:03
-
quinta-feira, 17 de setembro de 2009 19:54Running into the same type of problem as in the first post. It seems the PerformanceCounters aren't there. When I run
$Server = "name of server here"
[System.Diagnostics.PerformanceCounterCategory]::GetCategories($Server)
nothing related to MSMQ shows up. Maybe it's an MSMQ thing? -
quinta-feira, 17 de setembro de 2009 20:15Moderadorsounds like it... they show up for me (although I can not swear to the code I gave you as my server is not doing much.)
Brandon Shell [MVP] -
sexta-feira, 18 de setembro de 2009 15:34
I also get no counters on my Dell or IBM servers running Server 2003 R2 or Server 2008.
I DO get counters from VMWare running Server 2008
Karl -
sexta-feira, 18 de setembro de 2009 15:42Aaaargh! Windows security gets me again. One of the network analysts here said to try it running Powershell with Administrator access. Once I did that, I can now see the MSMQ Queue in the categories. I still have to cobble together a script, but don't have time right now. I'll report back when/if I can get something working.

