OSD: Change Volume Name

Lets say you need to change/rename the volume name of the C: drive to the computername, as part of your OS deployment Task Sequence. This script will help you do that:

strComputer = "."
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
Set colDrives = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk where DeviceID = 'C:'")
For Each objDrive in colDrives
    objDrive.VolumeName = WshNetwork.ComputerName
    objDrive.Put_

Enjoy

+Ronni Pedersen

Next

Get new posts by email

Practical articles on Intune, Windows and endpoint security, plus Workplace Ninja meetups. No spam, unsubscribe anytime.