{"id":2511,"date":"2013-11-25T11:59:00","date_gmt":"2013-11-25T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/11\/25\/powertip-use-powershell-to-find-key-of-wmi-class\/"},"modified":"2013-11-25T11:59:00","modified_gmt":"2013-11-25T11:59:00","slug":"powertip-use-powershell-to-find-key-of-wmi-class","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-use-powershell-to-find-key-of-wmi-class\/","title":{"rendered":"PowerTip: Use PowerShell to Find Key of WMI Class"},"content":{"rendered":"<p><strong>Summary<\/strong>: Use Windows PowerShell to find the key of a WMI class.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\">&nbsp;How can I use Windows PowerShell to discover the property that has the key qualifier for a WMI class? &nbsp;<\/p>\n<p style=\"padding-left: 60px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\">&nbsp;Use&nbsp;<strong>Get-CimClass<\/strong>&nbsp;and iterate through the properties:<\/p>\n<p style=\"padding-left: 120px\">$class = Get-CimClass -ClassName Win32_Process<\/p>\n<p style=\"padding-left: 120px\">foreach ($property in $class.CimClassProperties) {<\/p>\n<p style=\"padding-left: 120px\">&nbsp;$property | select -ExpandProperty Qualifiers |<\/p>\n<p style=\"padding-left: 120px\">&nbsp;foreach {<\/p>\n<p style=\"padding-left: 120px\">&nbsp;&nbsp; if ($_.Name -eq &#8216;key&#8217;){<\/p>\n<p style=\"padding-left: 120px\">&nbsp;&nbsp;&nbsp;&nbsp; $property<\/p>\n<p style=\"padding-left: 120px\">&nbsp;&nbsp; }<\/p>\n<p style=\"padding-left: 120px\">&nbsp;}<\/p>\n<p style=\"padding-left: 120px\">&nbsp;}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use Windows PowerShell to find the key of a WMI class. &nbsp;How can I use Windows PowerShell to discover the property that has the key qualifier for a WMI class? &nbsp; &nbsp;Use&nbsp;Get-CimClass&nbsp;and iterate through the properties: $class = Get-CimClass -ClassName Win32_Process foreach ($property in $class.CimClassProperties) { &nbsp;$property | select -ExpandProperty Qualifiers | &nbsp;foreach { [&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":[356,189,45,6],"class_list":["post-2511","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powertip","tag-richard-siddaway","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Use Windows PowerShell to find the key of a WMI class. &nbsp;How can I use Windows PowerShell to discover the property that has the key qualifier for a WMI class? &nbsp; &nbsp;Use&nbsp;Get-CimClass&nbsp;and iterate through the properties: $class = Get-CimClass -ClassName Win32_Process foreach ($property in $class.CimClassProperties) { &nbsp;$property | select -ExpandProperty Qualifiers | &nbsp;foreach { [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2511","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=2511"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2511\/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=2511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}