Could you not deploy a package like below.
net config server /srvcomment:"%COMPUTERNAME%"
We currently don't update the computer description but we label the C drive with the computer name using the following.
LABEL C:%COMPUTERNAME%
We also have a script which writes the computer info into AD.
' This script changes a computer's description as well as registers it in active directory with the serial number and last logged in user.
' If you want this to update automatically, make this a logon script in group policy.
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colsystemenclosure = objwmiservice.execquery("Select * from Win32_SystemEnclosure")
' Get Serial number
For Each objcomputer In colsystemenclosure
serialnumber = Trim(objcomputer.serialnumber)
Next
'get AD user
Set adsinfo = CreateObject("adsysteminfo")
Set adcomputer = GetObject("LDAP://" & adsinfo.ComputerName)
Set aduser = GetObject("LDAP://" & adsinfo.UserName)
username = aduser.cn
strcomputer = wshnetwork.computername
Set objwmiservice = GetObject("winmgmts:{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")
Set colcomputer = objwmiservice.execquery("Select * from Win32_computersystem")
Set colcomputerdisk = objwmiservice.execquery("Select * from Win32_diskdrive")
Set coloperatingsystem = objwmiservice.execquery("Select * from Win32_OperatingSystem")
Set colsystemenclosure = objwmiservice.execquery("Select * from Win32_SystemEnclosure")
Set colmacid = objWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID = 'Local Area Connection'")
'get model
For Each objcomputer In colcomputer
cpumanufacturer = objcomputer.manufacturer
cpumodel = Trim(objcomputer.model)
Next
' Get OS version
For Each objcomputer In coloperatingsystem
servicepack = objcomputer.servicepackmajorversion
osver = objcomputer.name
osver1 = Mid( osver, 18,3)
Next
'Pull the machine description. This can be formatted however you want. We use a "RM:" then a five letter description filled in with leading zeros.
desc = GetDesc()
'sets the information in AD
'adcomputer.put "description", "LU: " & username & ", PC: " & desc & ", OS: " & osver1 & ", Mod: " & cpumodel & ", SN: " & ucase(serialnumber)
'adcomputer.put "description", "LU: " & username & ", OS: " & osver1 & ", Mod: " & cpumodel & ", SN: " & ucase(serialnumber)
adcomputer.put "description", "" & username & ", OS: " & osver1 & ", Mod: " & cpumodel & ", SN: " & ucase(serialnumber)
adcomputer.Setinfo
'This bit sets the last logged on user as the "phonetic display name" in AD. It makes it easy to figure out what computer someone is talking about just by adding a column.
'adcomputer.put "msDS-PhoneticDisplayName", "Last User: " & username
'adcomputer.setinfo
Function GetDesc()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT Description FROM Win32_OperatingSystem")
For Each objItem in colItems
desc = objItem.Description
Next
GetDesc = desc
End Function
Function GetUser()
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
user = objComputer.UserName
Next
GetUser = user
End Function