Naming the C: drive partition the same as the computername.
This script sample changes the volume label for drive C to "Finance Volume". Use a get-computername function to change the name to the current computername.
Run the script as part of your Task Secquence (after the client are re-imaged).
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDrives = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk where DeviceID = 'C:'")
For Each objDrive in colDrives
objDrive.VolumeName = "Finance Volume"
objDrive.Put_
NextRonni Pedersen | Configuration Manager MVP | Blog:
http://www.ronnipedersen.com/ | Twitter
@ronnipedersen
April 13th, 2011 10:50am
This should work:
strComputer = "."
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDrives = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk where DeviceID = 'C:'")
For Each objDrive in colDrives
objDrive.VolumeName = WshNetwork.ComputerName
objDrive.Put_
Next
Ronni Pedersen | Configuration Manager MVP | Blog:
http://www.ronnipedersen.com/ | Twitter
@ronnipedersen
Free Windows Admin Tool Kit Click here and download it now
April 13th, 2011 10:57am
I had a play with Task sequnce variables but to no avail yet. Is there a way in a task sequence to get the C: partition to be named the same as the OSDcomputername or the netbios name? This would have to work for first time builds and rebuilds. cheers.
April 13th, 2011 11:58am
Thanks for that Ronni, It worked a treat.
Free Windows Admin Tool Kit Click here and download it now
April 14th, 2011 9:14am