{"id":8761,"date":"2012-07-10T00:01:00","date_gmt":"2012-07-10T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/07\/10\/three-easy-ways-to-use-powershell-and-wql-to-get-wmi-data\/"},"modified":"2012-07-10T00:01:00","modified_gmt":"2012-07-10T00:01:00","slug":"three-easy-ways-to-use-powershell-and-wql-to-get-wmi-data","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/three-easy-ways-to-use-powershell-and-wql-to-get-wmi-data\/","title":{"rendered":"Three Easy Ways to Use PowerShell and WQL to Get WMI Data"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft Scripting Guy, Ed Wilson, talks about using WMI Query Language and Windows PowerShell to get WMI data.\n<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\"> Hey, Scripting Guy! What is WQL? It sounds like SQL, but that does not always mean very much. I mean, General Electric and General Motors sound alike, but they do not have much in common. So back to my question, do you know what WQL is?\n&mdash;WS\n<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\"> Hello WS,\nMicrosoft Scripting Guy, Ed Wilson, is here. Things are all in a flutter here in Charlotte, North Carolina in the United States. Our weather has been abysmal. It has been hovering around 105 degrees Fahrenheit (40.5 degrees Celsius, according to my <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/02\/21\/hey-scripting-guy-february-21-2010.aspx\" target=\"_blank\">conversion module<\/a>). With all this heat, we began dreaming of cool places, and so we booked a trip to Germany. Unfortunately, it will not be until November, but at least we will escape the heat and get a chance to see many of our Windows PowerShell friends who we have met over the years and those who we want to meet. We already have three dates lined up in some of our favorite cities. Tonight, the best we can do is go out for dinner and a movie with Brian (one of our Charlotte Windows PowerShell User Group friends).\nWS, of course I know what WQL is&mdash;I wrote the book on WMI: <a href=\"http:\/\/www.amazon.com\/Microsoft-Windows-Scripting-WMI-Self-Paced\/dp\/0735622310\/ref=sr_1_2?ie=UTF8&amp;qid=1341849440&amp;sr=8-2&amp;keywords=wmi\" target=\"_blank\">Microsoft Windows Scripting with WMI: Self-Paced Learning Guide<\/a>. I am also contributing a chapter to a new book about Windows PowerShell and SQL Server 2012 written by Laerte Junior, Bob Beachumin, and Mark Broadbent.<\/p>\n<h2>WMI Query Language<\/h2>\n<p>Here is one of those &ldquo;bad news&rdquo; things. WQL is WMI Query Language. WMI stands for Windows Management Instrumentation. So one would think that WQL really is Windows Management Instrumentation Query Language; but it probably is not. There is documentation on MSDN, for example, <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa394606(v=vs.85).aspx\" target=\"_blank\">WQL (SQL for WMI)<\/a>, but it is more or less COM based, and while it is comprehensive, it is more extensive than a typical Net Admin or IT Pro would need to do. The basic WQL statements that you need to know are <b>Select<\/b><i>, <\/i><b>From<\/b><i>, <\/i>and <b>Where<\/b><i>. <\/i><\/p>\n<h2>Using the Select statement<\/h2>\n<p>A typical WMI query begins by using the <b>Select<\/b><i> <\/i>statement to choose everything or only a few properties from a WMI class. To choose all properties from a WMI class, you use the asterisk (&ldquo;*&rdquo;). After you have selected the properties (one or more properties, or all of them), you use the <b>From<\/b><i> <\/i>keyword to list which WMI class to query. The following script creates a WQL query that chooses all properties from the Win32_Bios WMI class:<\/p>\n<p style=\"padding-left: 30px\">$query = &#8220;Select * from Win32_Bios&#8221;\nTo choose a single property from the WMI class, you place the property name after the <b>Select<\/b> keyword and before the <b>From<\/b><i> <\/i>keyword. In the following query, only the name of the BIOS is selected from the Win32_Bios WMI class.<\/p>\n<p style=\"padding-left: 30px\">$queryName = &#8220;Select Name from Win32_Bios&#8221;\nIf you want to select more than one property, you separate the property names by commas. Therefore, the following WMI query chooses the name and the version from the Win32_Bios WMI class.<\/p>\n<p style=\"padding-left: 30px\">$queryNameVersion = &#8220;Select name, version from WIn32_Bios&#8221;<\/p>\n<h2>Using the WQL query<\/h2>\n<p>So how do you use the WQL query to retrieve information from a system? In Windows PowerShell&nbsp;2.0, there are two main ways to do this. The first is to use the <b>Get-WmiObject<\/b> cmdlet, and the second is to use the [wmisearcher] type accelerator. The [wmisearcher] type accelerator creates a <b>ManagementObjectSearcher<\/b> class. The <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.management.managementobjectsearcher.aspx\" target=\"_blank\">ManagementObjectSearcher class<\/a> is documented on MSDN, but the thing you really need to know how to use is the <b>Get<\/b><i> <\/i>method. This will be discussed later in this section. In Windows PowerShell&nbsp;3.0, the CIM cmdlets also accept a WQL query. I will talk about using the CIM cmdlets at a later date.<\/p>\n<h3>Query by using the Get-WmiObject cmdlet<\/h3>\n<p>The first way is to use the WQL query with the <b>Get-WmiObject<\/b> cmdlet. To do this, you use the <i>Query <\/i>parameter. The command is shown here:<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $query = &#8220;Select * from Win32_Bios&#8221;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Get-WmiObject -Query $query<\/p>\n<p style=\"padding-left: 30px\">SMBIOSBIOSVersion : 8BET56WW (1.36 )<\/p>\n<p style=\"padding-left: 30px\">Manufacturer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : LENOVO<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS<\/p>\n<p style=\"padding-left: 30px\">SerialNumber&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : R9FPY3P<\/p>\n<p style=\"padding-left: 30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : LENOVO &ndash; 1360\nLet&rsquo;s use our other queries to see how they fare. First, select only the name of the bios as shown here.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $queryName = &#8220;Select Name from Win32_Bios&#8221;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Get-WmiObject -Query $queryName<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<\/p>\n<p style=\"padding-left: 30px\">__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_BIOS<\/p>\n<p style=\"padding-left: 30px\">__SUPERCLASS&nbsp; &nbsp;&nbsp;&nbsp;:<\/p>\n<p style=\"padding-left: 30px\">__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PROPERTY_COUNT : 1<\/p>\n<p style=\"padding-left: 30px\">__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<\/p>\n<p style=\"padding-left: 30px\">__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS<\/p>\n<p style=\"padding-left: 30px\">Now, let&rsquo;s choose the name and version query and use it.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $queryNameVersion = &#8220;Select name, version from WIn32_Bios&#8221;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Get-WmiObject -Query $queryNameVersion<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<\/p>\n<p style=\"padding-left: 30px\">__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_BIOS<\/p>\n<p style=\"padding-left: 30px\">__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PROPERTY_COUNT : 2<\/p>\n<p style=\"padding-left: 30px\">__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<\/p>\n<p style=\"padding-left: 30px\">__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS<\/p>\n<p style=\"padding-left: 30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : LENOVO &#8211; 1360<\/p>\n<h3>Query by using the [wmisearcher] type accelerator<\/h3>\n<p>By using the [wmisearcher], you gain easy access to the <b>ManagementObjectSearcher<\/b> .NET Framework class. This provides you not only with the ability to query WMI for information, but also to configure the way that query is conducted. There are three basic steps to using the [wmisearcher] type accelerator.\n<b>Just the steps&#8230;<\/b>\nTo use the [wmisearcher] type accelerator<\/p>\n<ol>\n<li>Put the WQL query in a variable.<\/li>\n<li>Use the [wmisearcher] to cast the WQL string into a <b>ManagementObjectSearcher <\/b>object.<\/li>\n<li>Call the <b>Get<\/b><i> <\/i>method from the <b>ManagementObjectSearcher<\/b> object.<\/li>\n<\/ol>\n<p>This may sound more complicated than it is. In fact, it is very simple. Here is an example of using WQL to return all of the properties from the <b>Win32_Bios<\/b> class.\n<b>Note<\/b>&nbsp;&nbsp;&nbsp;Not all of the properties display due to the format*XML file that specifies which properties to return.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $query = &#8220;Select * from Win32_Bios&#8221;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $bios = [wmisearcher]$query<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $bios.Get()<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">SMBIOSBIOSVersion : 8BET56WW (1.36 )<\/p>\n<p style=\"padding-left: 30px\">Manufacturer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : LENOVO<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS<\/p>\n<p style=\"padding-left: 30px\">SerialNumber&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : R9FPY3P<\/p>\n<p style=\"padding-left: 30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : LENOVO &ndash; 1360\nIn the same way that WQL reduces the properties selected for use with the <b>Get-WmiObject<\/b> cmdlet, the same methodology can be used with the [wmisearcher] type accelerator. In the example shown here, only the <b>Name<\/b> property returns from the query.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $queryName = &#8220;Select Name from Win32_Bios&#8221;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $biosname = [wmisearcher]$queryName<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $biosname.Get()<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<\/p>\n<p style=\"padding-left: 30px\">__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_BIOS<\/p>\n<p style=\"padding-left: 30px\">__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PROPERTY_COUNT : 1<\/p>\n<p style=\"padding-left: 30px\">__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<\/p>\n<p style=\"padding-left: 30px\">__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS\nBut, rather than storing the string in a variable, then casting the string into a <b>ManagementObjectSearcher<\/b> type, and then calling the <b>Get<\/b><i> <\/i>method, you can skip one of the steps and still have decent readability. This works because in the previous example, the WQL string was stored in a variable. The variable was then cast into the <b>ManagementObjectSearcher<\/b> type, and then the method was called. The code shown here skips one of the steps and casts the string directly to the object, and then stores the resulting object in the variable.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $biosname = [wmisearcher]&#8221;Select name from win32_bios&#8221;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $biosname.Get()<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<\/p>\n<p style=\"padding-left: 30px\">__CLASS &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: Win32_BIOS<\/p>\n<p style=\"padding-left: 30px\">__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PROPERTY_COUNT : 1<\/p>\n<p style=\"padding-left: 30px\">__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<\/p>\n<p style=\"padding-left: 30px\">__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS\nA more interesting way of doing this (and perhaps a bit more readable) is to leave the WQL string on the right side of the equality operator, and perform the cast to <b>ManagementObjectSearcher<\/b> on the variable. This code is even cleaner, and it allows for easier modification of the WQL query.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; [wmisearcher]$biosname = &#8220;Select name from win32_bios&#8221;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; $biosname.Get()<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<\/p>\n<p style=\"padding-left: 30px\">__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_BIOS<\/p>\n<p style=\"padding-left: 30px\">__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PROPERTY_COUNT : 1<\/p>\n<p style=\"padding-left: 30px\">__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<\/p>\n<p style=\"padding-left: 30px\">__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS\nWe can even perform this query in a single line. This works because the [wmisearcher] casts the WQL string to a <b>ManagementObjectSearcher<\/b>. From that object the <b>Get<\/b><i> <\/i>method is available. By using the parentheses <b>()<\/b> to group the cast to the <b>ManagementObjectSearcher<\/b> first, the <b>Get<\/b><i> <\/i>method becomes available.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; ([wmisearcher]&#8221;Select name from win32_bios&#8221;).get()<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<\/p>\n<p style=\"padding-left: 30px\">__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_BIOS<\/p>\n<p style=\"padding-left: 30px\">__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PROPERTY_COUNT : 1<\/p>\n<p style=\"padding-left: 30px\">__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<\/p>\n<p style=\"padding-left: 30px\">__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS<\/p>\n<h2>Using the query directly<\/h2>\n<p>Of course, you do not have to store your query in a variable. You can type the query directly into the <i>Query <\/i>position in your command. Although this may have advantages in simplicity (you have one command instead of two), it also makes your code more difficult to read. This approach is shown here:<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Get-WmiObject -Query &#8220;Select * from win32_bios&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">SMBIOSBIOSVersion : 8BET56WW (1.36 )<\/p>\n<p style=\"padding-left: 30px\">Manufacturer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : LENOVO<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Default System BIOS<\/p>\n<p style=\"padding-left: 30px\">SerialNumber&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: R9FPY3P<\/p>\n<p style=\"padding-left: 30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : LENOVO &#8211; 1360\nWS, that is all there is to using WQL. WMI Week will continue tomorrow when I will talk about limiting information that is returned by the WQL query. I will also talk about all those extra &shy;&shy;system properties that were returned by WMI when we attempted to limit the properties.\nI invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.\n<b>Ed Wilson, Microsoft Scripting Guy<\/b>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using WMI Query Language and Windows PowerShell to get WMI data. Hey, Scripting Guy! What is WQL? It sounds like SQL, but that does not always mean very much. I mean, General Electric and General Motors sound alike, but they do not have much in common. So [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3,4,45,6],"class_list":["post-8761","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using WMI Query Language and Windows PowerShell to get WMI data. Hey, Scripting Guy! What is WQL? It sounds like SQL, but that does not always mean very much. I mean, General Electric and General Motors sound alike, but they do not have much in common. So [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/8761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=8761"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/8761\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=8761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=8761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=8761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}