#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.

About the author: Ravikanth C

Ravikanth is the founder and editor of the PowerShell Magazine. He is also a PowerShell MVP who works at Dell Inc. He blogs at http://www.ravichaganti.com/blog and you can follow him on Twitter @ravikanth.

Related Posts

%d bloggers like this: