‎05-16-2014 01:10 AM
' Get computer object in AD
strComputer = WScript.Arguments(0)
Const ADS_SCOPE_SUBTREE = 2
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
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
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.")
Wscript.Quit
End If
' Write to AD computer object
objComputer.Put "Description" , newDescription
objComputer.SetInfo
‎10-27-2020 12:39 PM
‎10-04-2020 05:46 PM
‎05-19-2014 06:29 PM
‎05-16-2014 11:19 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now