#PSTip Modifying WMI Object properties using Get-WmiObject cmdlet

Get-WmiObject and object modification! Sounds contradictory? Not really. That is the beauty of PowerShell and its object-based nature. Let us see an example to understand this.

$vol = Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID='E:'"
$vol.VolumeName = "Memory Card"

Now, setting the VolumeName to “Memory Card” isn’t enough.


The Put() method ensures that the changes made to the object are written back. Make a note that you must have administrative rights to update some of the WMI object properties.

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