Delegate users to allow them to change their description in AD
Create a VBS file containing the following code
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
' Get service tag and computer manufacturer
For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")
Next
' Get computer model
For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")
model = trim(replace(objComputer.Model, ",", "."))
Next
' Get computer object in AD
Set objSysInfo = CreateObject("ADSystemInfo")
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
' Get user object in AD
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
' Get all IP addresses
Dim NIC1, Nic, StrIP
StrIP=""
Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each Nic in NIC1
if Nic.IPEnabled then
For Each ip in Nic.IPAddress
If Len(StrIP)=0 then
StrIP = ip
Else
StrIP = StrIP & ", " & ip
End if
Next
End if
Next
' Build up description field data and save into computer object if different from current description
newDescription = objUser.LastName & " " & objUser.FirstName & " (" & WshNetwork.UserName & ") - " & manufacturer & " " & model & " (" & serviceTag & ") [" & StrIP & "]"
' We also do not update computers with a description that starts with an underscore (_)
if not objComputer.Description = newDescription and not left(objComputer.Description,1) = "_" then
objComputer.Description = newDescription
objComputer.SetInfo
end if
'WScript.StdOut.WriteLine newDescription
Next time the computers refresh their GPO, the logon script should run and every computer object should have the description like:
Last_name First_name (samaccountname) - vendor model (serial number)
Computers with description starting with _ will not have their description changed