Here's an example of using the ManagementClass and enumerating with for each:
[System.Management.ManagementClass]$mc = New-Object System.Management.ManagementClass
$mc.Path.NamespacePath = "root\cimv2"
$mc.Path.Classname = "Win32_Process"
$mc.Scope.Options.Authentication = 6
$mc.Scope.Options.Imersponation = 3
$moc = $mc.GetInstances
foreach($mm in $moc)
{
foreach($prop in $mo.Properties)
{
$v = 30
#$v = $v - $prop.Name.ToString().Length
write-host $prop.Name.PadRight($v, " ") : $prop.Value
}
}
No comments:
Post a Comment