Update ad computer description VBA

lite

New Member
Joined
Feb 22, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
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!!!

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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
for the life of me i cant figure out how to delete my post sorry! Figured it out, thank you everyone!
 
Upvote 0
for the life of me i cant figure out how to delete my post sorry!
You can't delete a post on the board. In fact, it could help another future reader, so if you have a solution then please consider sharing it with the community.

If you would like to post your own solution then it is perfectly fine to mark your post as the solution to help future readers. Otherwise, please do not mark a post that doesn't contain a solution.
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,119
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top