Tuesday, April 29, 2014

Powershell: How to filter for specific groups of WMI classes

$ns
function enumclasses
{
    $classnames = Get-WmiObject -namespace $ns -class Meta_Class | select name  
    foreach($cn in $classnames)
    {
        $pos = $cn.Name.IndexOf("Win32")
        if($pos -gt -1)
        {
            write-host $cn.Name
        }   
    }        
}  

$ns = "root\cimv2"
enumclasses

No comments:

Post a Comment