Here’s a combined script, be sure to test!
Dim objShell, objADSysInfo
Set objShell = CreateObject(“WScript.Shell”)
Set objADSysInfo = CreateObject(“ADSystemInfo”)
'These are the registry keys for the description broadcast in Network Neighborhood
'and for the caption/title bar shown when hitting ctrl-alt-del
Dim strRegSrvComment, strRegWelcome, strLocalDescription
on error resume next
strRegSrvComment = “”
strRegWelcome = “”
strRegSrvComment = “HKLM\System\CurrentControlSet\Services\lanmanserver\parameters\SrvComment”
strRegWelcome = “HKLM\Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Welcome”
strLocalDescription = objShell.RegRead(strRegSrvComment)
'Get the Active Directory Distinguished name for the current computer
Dim strADComputer, strLocalComputer
strADComputer = objADSysInfo.ComputerName
strLocalComputer = objShell.ExpandEnvironmentStrings(“%COMPUTERNAME%”)
'Lets log to the Windows event log what we are doing
objShell.LogEvent 0,"Starting CompDescription Sub: " & strADComputer & " " & strLocalComputer
'Get the Active Directory Object for the current computer
Dim objADComputer, strADDescription
Set objADComputer = GetObject(“LDAP://” & strADComputer)
'Place AD computer description into variable
strADDescription = objADComputer.Description
'Get the Local Object for the current computer
Dim objLocalComputer, colEncl
Set objLocalComputer = GetObject(“winmgmts:\” & strLocalComputer & “\root\cimv2”)
Set colEncl = objLocalComputer.ExecQuery(“Select SerialNumber from Win32_SystemEnclosure”,48)
'Get the system serial number must be less than seven chars (Dell is usually 7 exactly unless really old then its 5)
Dim objEncl
For Each objEncl in colEncl
If Len(oobjEnclSerialNumber) <= 7 Then
strSerialNumber = objEncl.SerialNumber
End If
Next
'Compare the Active Directory description with the Local computer description
If LCase(strADDescription) <> LCase(strLocalDescription) Then
'if the descriptions don’t match we’ve got a change.
'Let’s log an event to WIndows recognizing this
objShell.LogEvent 0,“AD and Local description do not match” & strADDescription & " " & strLocalDescription
If strADDescription <> “” Then
'Setting local description using net config
objShell.LogEvent 0,"Setting Local Description to the one in AD: " & strADDescription
objShell.Run “net config server /srvcomment:” & Chr(34) & strADDescription & Chr(34)
strDescription = strADDescription
Else
'Writing to AD
objShell.LogEvent 0,"Setting AD Description to the one from the system: " & strLocalDescription
objADComputer.Put “description”,strLocalDescription
objADComputer.SetInfo
strDescripton = strLocalDescription
End If
'Since we have a change in Description lets reflect that on the CTRL-ALT-DEL screen so the user
'can see our hard work which will be the logon caption bar text:
'Windows Security | ComputerName | Description ------if the serial number is in the computername
'Windows Security | Computername | Serial Number | Description ------if the serial isn’t in the compname
If InStr(strLocalComputer,strSerialNumber) = 0 Then
objShell.RegWrite strRegWelcome,“| " & strLocalComputer & " | " & strSerialNumber & " | " & strDescription
Else
objShell.RegWrite strRegWelcome,”| " & strLocalComputer & " | " & strDescription
End If
End If
On Error Resume Next
strLocalComputer = “.”
Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & strLocalComputer & “\root\cimv2”)
Set colcomputersystem = objWMIService.ExecQuery (“Select Model from Win32_computersystem”)
Set colBIOS = objWMIService.ExecQuery(“Select SerialNumber from Win32_BIOS”)
For each objcomputersystem in colcomputersystem
Getcomputersystem = objcomputersystem.Model
Next
For each objBIOS in colBIOS
GetSerialNumber = objBIOS.SerialNumber
Next
Set objSysInfo = CreateObject(“ADSystemInfo”)
Set objUser = GetObject(“LDAP://” & objSysInfo.UserName)
Set objComputer = GetObject(“LDAP://” & objSysInfo.ComputerName)
strMessage = objUser.CN & " / " & GetSerialNumber & " / " & Getcomputersystem
'Lets update AD computer description with the updated info
objComputer.Description = strMessage
objComputer.SetInfo
'cleanup
Set objADComputer = Nothing
Set objLocalComputer = Nothing
Set objEncl = Nothing
Set objShell = Nothing
Set objADSysInfo = Nothing
Set objComputer = Nothing
Set objUser = Nothing
Set objSysInfo = Nothing