I have a WMI query of an MSMQ queue that works fine as long as there are messages in the queue:
Select MessagesInQueue From Win32_PerfRawData_msmq_MSMQQueue where Name="os:servername\\private$\\queuename")
But when there are no messages in the queue, it gets torn down and that queue name no longer exists. When that happens I would like to return a 0, but the following returns an "Invalid Query" error:
IF EXISTS (Select * from Win32_PerfRawData_msmq_MSMQQueue where Name="os:servername\\private$\\queuename")
THEN (Select MessagesInQueue From Win32_PerfRawData_msmq_MSMQQueue where Name="os:servername\\private$\\queuename") ELSE 0
Any help?