Setting Computer AD Description Attribute

Posted: Friday, May 16, 2014 12:10:56 AM(UTC)


Member Original PosterPosts: 31
I wanted to share a custom action that I created that has helped me tremendously. This custom action will change the AD Description for what ever computer asset your on.

It calls on a vbscript file called changeADCompDesc.vbs and passes the computer name. Then it prompts for the new description and if it is not blank then it will set it in AD.

Here is the vbscript code:


' Get computer object in AD
strComputer = WScript.Arguments(0)


Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 

objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://dc=domain,dc=com' WHERE objectCategory='computer' and name = '" & strComputer & "'"
Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
     strDN = objRecordSet.Fields("distinguishedName").Value

Set objComputer = GetObject("LDAP://" & strDN)

' Input new AD computer description field
newDescription = InputBox("Please enter the new AD Computer Description: ", "New description")
If newDescription = "" Then
	Wscript.Echo ("Invalid description and this script will quit.")
End If

' Write to AD computer object	
objComputer.Put "Description" , newDescription

Save the code as changeCompDesc.vbs and save it into your action folder on the Lansweeper server.
Remember to change the domain in line 15 to your own domain.
#1Lansweeper Member Posts: 13,442  
posted: 5/16/2014 10:19:09 PM(UTC)
Thanks for posting!
#2jacobsenm Member Posts: 63  
posted: 5/19/2014 5:29:34 PM(UTC)
I was waiting for this one very long.
Good post ! Thank you,
#3DJSMC Member Posts: 2  
posted: 10/4/2020 4:46:17 PM(UTC)
Is anyone else having issue with this action?

I am getting a error:

Windows Script Host
Line: 18
Char: 1
Error: Either BOF or EOF is True, or the current record has been deleted. Requestd operation requires current record.
Code: 800A0BCD
Source: ADODB.RecordSet

Active Discussions

Lansweeper Assets with different MACs/IPs getting merged
by  MartinO   Go to last post Go to first unread
Last post: Yesterday at 3:15:25 PM(UTC)
Lansweeper Where is Extension Attribute 1
by  CoolDood  
Go to last post Go to first unread
Last post: 10/22/2020 8:45:46 PM(UTC)
Lansweeper Accessing IMEI/MEID fields for manual assets
by  Tom Londe   Go to last post Go to first unread
Last post: 10/22/2020 5:31:27 PM(UTC)
Lansweeper Server 2019 Version Numbers
by  MCBowman   Go to last post Go to first unread
Last post: 10/22/2020 2:35:32 PM(UTC)
Lansweeper Wake on Lan Issues
by  brodiemac-too  
Go to last post Go to first unread
Last post: 10/21/2020 4:48:10 PM(UTC)