Rename Drive Label

WMI can also read any drive label (the name that appears next to a drive inside Explorer), and you can change the drive label, too—provided you have administrator privileges. This code renames drive c:\ to "My Harddrive":

$drive = [wmi]"Win32_logicaldisk='C:'"
$drive.VolumeName = "My Harddrive"
$drive.Put()

Just make sure to call Put() so your changes will get written back to the original object.

Twitter This Tip! ReTweet this Tip!


Posted Jul 23 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.