VMware Cloud Community
GulzarA
Contributor
Contributor

WMI Query for win32_product

hi, 

How I can achieve the below power shell script using "queryWMI" action

Get-WmiObject win32_product | where-object name -like "MongoDB*"

 

<queryWMI>
<class>win32_product</class>
<fields>Name;Version;Vendor</fields>
<run>0</run>
<variable>result</variable>
<where>name -like "MongoDB*"</where>
</queryWMI>

0 Kudos
3 Replies
gongomgra
VMware Employee
VMware Employee

Hi @GulzarA ,

Thanks for your message. I was able to get the information using a slightly different snippet. Can you try it?

<queryWMI>
  <class>win32_product</class>
  <fields>Name;Version;Vendor</fields>
  <run>1</run>
  <variable>result</variable>
  <where>name like "MongoDB%"</where>
</queryWMI>

Notice I'm not using the parameters in the same way that the Get-WmiObject command expects them in Powershell, but kind of a SQL format, and also that I'm setting the run parameter with value 1.

0 Kudos
GulzarA
Contributor
Contributor

The sample works perfectly, Thank you , correction made in this tag <where>name like "MongoDB%"</where>

with regards

Gulzar

0 Kudos
gongomgra
VMware Employee
VMware Employee

Hi @GulzarA ,

Thanks for your message. I'm glad the provided snippet solved your issue!

0 Kudos