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


+Ronni Pedersen


About Author

My name is Ronni Pedersen and I'm currently working as a Cloud Architect at APENTO in Denmark. My primary focus is Enterprise Client Management solutions, based on technologies like AzureAD, Intune, EMS and System Center Configuration Manager. I'm is also a Microsoft Certified Trainer and Microsoft MVP in Enterprise Mobility.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.