Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Use PowerShell to Find Key of WMI Class

$
0
0

Summary: Use Windows PowerShell to find the key of a WMI class.

Hey, Scripting Guy! Question How can I use Windows PowerShell to discover the property that has the key qualifier for a WMI class?  

Hey, Scripting Guy! Answer Use Get-CimClass and iterate through the properties:

$class = Get-CimClass -ClassName Win32_Process

foreach ($property in $class.CimClassProperties) {

 $property | select -ExpandProperty Qualifiers |

 foreach {

   if ($_.Name -eq 'key'){

     $property

   }

 }

 }


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>