Script to populate AD computer object with username, PC type and time

I place the VBS in the netlogon folder and call it from within the main login script in the case of legacy systems. If using GPO based scripting, you can call it from a standalone script, or whatever you choose. It just needs to be run.

call %LOGONSERVER%\netlogon\adinfo.vbs

You need to set your users to be able to update the Computer Objects Properties, you can do this, for example on the whole domain as below, or parts thereof. Obviously, you don’t want to be doing this on terminal servers or similar, it’s up to you how you choose to run it. Also, be aware, that if you have a large AD, especially if DC’s are separated by slow WANs this may cause a replication headache – but if you are administrating an AD of that size I am sure you can work something out.

From AD Users and Computers MMC (ADUC)
Properties of your Domain
=> Security Tab => “Advanced”
Add “Authenticated Users” to “Descendant Computer objects”
Permissions: “Write all properties”

VBS I use is:


' When used as login script it will populate the Computer Description
' in Active Directory with UserName, Computer Model & Time

' ----------------------------------------------------------------------
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colcomputersystem = objWMIService.ExecQuery _
("Select * from Win32_computersystem")
For each objcomputersystem in colcomputersystem
Getcomputersystem = objcomputersystem.Model

Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
strMessage = objUser.CN & " / " & Getcomputersystem & " -- " & Now()
objComputer.Description = strMessage


Thanks to Hendrik Wiese for original.

I have also, on some sites, made slight modifications, so it can track logoffs as well, which is useful for determining OOHours maintenance, etc.

This entry was posted in IT Stuff. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *