Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

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
0

Comments

5 comments
Date Votes
  • 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?

    0
  • 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.

    0
  • Recently I had a similar task at hand and I solved it with a small Powershell script. It's a quick 'n dirty solution that works without RSAT.

    I used PQD Deploy to run it on clients. Worked like a chram.

    0
  • 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
    0
  • Or just use cmd for a quick entry:

    net config server /srvcomment:"put_your_comment_here"

    0