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

$vol.Put()

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.

Share on: