0

#PSTip Get all writeable properties of a WMI class

Not all WMI class properties can be modified. Many of these properties are read-only. Take a look at the properties and Win32_ComputerSystem, for example.

WMI Properties

Now, how do we retrieve properties of a WMI class that are read/write capable? This can be achieved by looking at the property qualifiers. Let us see how:

$class = [wmiclass]'Win32_ComputerSystem'
$class.Properties | ForEach-Object {
      foreach ($qualifier in $_.Qualifiers) {
           if ($qualifier.Name -eq "Write") {
                $_.Name
           }
      }
}

Now, this can be easily extended to verify and list other qualifying properties such as data type, etc.

Filed in: Columns, Tips and Tricks Tags: , , ,

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: