Add Dynamic Data to AD Description Field

This shows you how to add [BITLOCKER timestamp machine model] to the computer object’s description field. Quite useful for populating more useful information into Active Directory. I’m using this as a post setup script to verify Bitlocker is installed, and when it was installed.

on error resume next

Set objWMI = GetObject(“winmgmts:”)
Set colSettings = objWMI.ExecQuery(“Select * from Win32_ComputerSystem”)

For Each objComputer in colSettings
on error resume next
LaptopModel = Trim(objComputer.Model)
Next

if strModel = “” then
on error resume next
‘msgbox “no model was detected”
myLength = Len(LaptopModel)

For i = 1 To myLength
on error resume next
If Asc(Mid(LaptopModel, i, 1)) <> 32 Then
If Asc(Mid(LaptopModel, i, 1)) >= 48 And Asc(Mid(LaptopModel, i, 1)) <= 57 Then myNumber = myNumber & Mid(LaptopModel, i, 1) End If Else 'msgbox("no numeric") End If Next 'msgbox(myNumber) strModel = myNumber end if 'msgbox strModel Dim strSearchString, strSearchFor Set objSysInfo = CreateObject("ADSystemInfo") Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName) strSearchString = objComputer.Description strSearchFor = "Bitlocker" If InStr(1, strSearchString, strSearchFor) > 0 then
‘if bitlocker is not found
strMessage = “BITLOCKER” & ” * ” & Now & ” * ” & strModel & ” * ” & objComputer.Description
Else
‘if bitlocker is found
strMessage = “BITLOCKER” & ” * ” & Now & ” * ” & strModel’ & ” ” & objComputer.Description
End If

objComputer.Description = strMessage
objComputer.SetInfo

email me