Edit Active Directory Description Script
I'm not sure if this is the right section for this, but I thought I would share.
After searching ad nauseam, I managed to piece together a script that allows me to edit the AD Description field using custom tools in PDQ Inventory. Most credit goes to this site for getting me started: http://4sysops.com/archives/automatically-fill-the-computer-description-field-in-active-directory/
I use the field to track location so I can see it in the main display of each collection in PDQ. Obviously you can edit this with your own criteria. Just create a .bat file with "Edit_AD_Description.vbs %Target%" and run it as a custom tool.
Edit_AD_Description.vbs
-
I would like to accomplish somewhat of the same thing. Except I would like to take the AD Description and updated the computer Description. I don't know if it would be better to query AD for the description or get it from PDQ Inventory. Anyone got an example of the best way to update the computer Description to match the AD Description?
-
I would try using reg.exe (http://technet.microsoft.com/en-us/library/cc732643.aspx) or RegJump (http://technet.microsoft.com/en-us/sysinternals/bb963880.aspx) to edit manually.
The key you want to edit is located here:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
You may have to create a new string value (REG_SZ) names srvComment.
-
Here is a VBS script I use to add the Admin, Serial Number, Model Number, Update Time to the AD Description. I run it in the Admin Context, as my users don't have the permissions in AD to update the field. (Which you can enable if you wish). If your users do have that ability, this script has the ability add the 'Logged in user' (objUser) to the description. Helpful to easily be able to see which PCs are assigned to which user when browsing AD. Since I can't do that, I just set Admin = John Doe.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colcomputersystem = objWMIService.ExecQuery _
("Select * from Win32_computersystem")
Set colBIOS = objWMIService.ExecQuery _
("Select * 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 = "Admin: John Doe / SN: " & GetSerialNumber & " / Model: " & Getcomputersystem & " / Update Time: " & right(year(now()),4) & "." & month(Now()) & "." & Day(now()) & " @ " & Time
objComputer.Description = strMessage
objComputer.SetInfo
Please sign in to leave a comment.
Comments
5 comments