Get WMI Class properties


posted by Thomas Lee
11-25-2008

Downloads: 615
File size: 740 B
Views: 4,851

Embed
Get WMI Class properties
  1. # get-wmiclassproperties.ps1 
  2. # Gets WMI Class property list using PowerShell 
  3. # Also gets property descrption and current value 
  4. # Thomas Lee - tfl@psp.co.uk 
  5.  
  6. # First, get the WMI class 
  7. $osClass = new-object system.management.ManagementClass Win32_Share 
  8. $osClass.Options.UseAmendedQualifiers = $true 
  9.  
  10. # Get the Properties in the class 
  11. $properties = $osClass.Properties 
  12. "This class has {0} properties as follows:" -f $properties.count 
  13.  
  14.  
  15. # display the Property name, description, type, qualifiers and instance values 
  16.  
  17. foreach ($property in $properties) { 
  18. "Property Name: {0}" -f $property.Name 
  19. "Description:   {0}" -f $($property.Qualifiers["Description"].Value
  20. "Type:          {0}" -f $property.Type 
  21. "-------" 
  22.  
This script uses WMI to get details about a given WMI class. In the sample, I use Win32_share, but you can substitute any WMI class name,
Copyright 2012 PowerShell.com. All rights reserved.