Writing Back WMI Property Changes

by Jan 3, 2013

Only a few properties in WMI objects are actually writeable although Get-Member insists they are all "Get/Set":

PS> Get-WmiObject -Class Win32_OperatingSystem | Get-Member -MemberType Properties

That's because WMI only provides "copies" of information to you, and you can do whatever you want. WMI won't care. To make WMI care and put property changes into reality, you need to send back your copy to WMI by calling Put(). This will change the description of your operating system: (if you have Admin rights):

PS> $os = Get-WmiObject -Class Win32_OperatingSystem
PS> $os.Description = 'I changed this!'
PS> $result = $os.PSBase.Put()

If you change a property that in reality is not writeable, you'll get an error message only once you try and write it back to WMI. The truly changeable WMI properties need to be retrieved from WMI:

PS> $class = [wmiclass]'Win32_OperatingSystem'
PS> $class.Properties | 
  Where-Object { $_.Qualifiers.Name -contains 'write' } |
  Select-Object -Property Name, Type

Twitter This Tip! ReTweet this Tip!