1

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

Filed in: Columns, Tips and Tricks Tags: , , ,

One Response to "#PSTip Modifying WMI Object properties using Get-WmiObject cmdlet"

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: