hello all!!!
I have a form in excel that has some list and text boxes that contain information I would like to be in the computer description in AD. I found some code that works, however, i would like the code to search for a given computer name and update the description in AD vs updating the description of the computer that i am currently on. I am assuming adding something to the LDAP on line 4 would be what I need, I am just not sure how to do it. Any help would be greatly appreciated!! thank you!!!
I have a form in excel that has some list and text boxes that contain information I would like to be in the computer description in AD. I found some code that works, however, i would like the code to search for a given computer name and update the description in AD vs updating the description of the computer that i am currently on. I am assuming adding something to the LDAP on line 4 would be what I need, I am just not sure how to do it. Any help would be greatly appreciated!! thank you!!!
VBA Code:
Sub test()
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objSysInfo = CreateObject("ADSystemInfo")
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
newDescription = "test3"
If Not objComputer.Description = newDescription Then
objComputer.Description = newDescription
objComputer.SetInfo
End If
End Sub