PowerShell for Windows Admins

Jun 27 2013   3:44PM GMT

Writable properties for a WMI class

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Do you know how to discover which properties on a WMI class, and therefore a WMI instance, can be modified?

Get-CimClass from the PowerShell 3.0 CIM cmdlets is the answer:

$class = Get-CimClass -ClassName win32_volume

The last command returns all of the properties in this format

Name : Description
Value :
CimType : String
Flags : Property, ReadOnly, NullValue
Qualifiers : {read}
ReferenceClassName :

Name : DriveLetter
Value :
CimType : String
Flags : Property, NullValue
Qualifiers : {read, write}
ReferenceClassName :

Notice the first one has a Flag of ReadOnly and the second one has a Qualifier of write. So the question becomes how can you filter on those two items?

If you run something like this:

$class = Get-CimClass -ClassName Win32_Volume
$class.CimClassProperties |
foreach {
if ($psitem | select -ExpandProperty Qualifiers | where Name -eq ‘write’){$psitem}
if (($psitem.Flags -split ‘, ‘) -notcontains ‘Readonly’) {$psitem}

You will see that some properties may not be Readonly but also aren’t writable such as:

Name : NumberOfBlocks
Value :
CimType : UInt64
Flags : Property, NullValue
Qualifiers : {MappingStrings}
ReferenceClassName :

In that case we need just the writable properties

Get-CimClass -ClassName Win32_Volume |
select -ExpandProperty CimClassProperties |
foreach {
if ($psitem | select -ExpandProperty Qualifiers | where Name -eq ‘write’){$psitem}

This brings the results down to three properties DriveLetter, IndexingEnabled, Label

The first and last I expected – IndexEnabled was new to me

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: