‎11-18-2014 02:42 PM - last edited on ‎07-04-2023 05:35 PM by ErikT
This package changes the computer description to (Model: SerialNumber or to the provided parameter name ex: CmpDesc.vbs "description_here") using the script "CmpDesc.vbs".
You can edit the description in the vbs file.
‎10-01-2015 07:30 PM
‎06-29-2017 08:57 PM
jacobsenm wrote:
Thanks both.
I actually was looking for chaging the AD computer object description.
For instance to populate it with the AD User Display Name.
This mightt be a bit more complicated.
Thanks
' 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
‎06-30-2017 05:21 AM
Charles wrote:jacobsenm wrote:
Thanks both.
I actually was looking for chaging the AD computer object description.
For instance to populate it with the AD User Display Name.
This mightt be a bit more complicated.
Thanks
Easy enough to do with an Action. Save the following to a file. I called mine adcompdesc.vbs
' 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
And as for the action itself, create an action with the following line:
runas.exe /user:DOMAIN\ADMINRIGHTSUSER "cscript {actionpath}adcompdesc.vbs {computer}"
The script requires you to have admin rights to Active Directory, and works like a champ.
‎10-01-2015 06:24 PM
Dim reg, objRegistry
Dim SN, M, ValueName, strComputer
Const HKLM = &H80000002
strComputer = "."
Set reg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
on error resume next
If WScript.Arguments.count = 0 Then
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("Select * FROM Win32_OperatingSystem")
For Each object In objRegistry
SN = object.SerialNumber
Next
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("Select * FROM Win32_ComputerSystem")
For Each object In objRegistry
M = object.Model
Next
value = M & ": " & SN
key = "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters"
ValueName = "srvcomment"
If Len(value) > 48 Then value = Left(value, 48)
reg.SetStringValue HKLM, key, ValueName, value
Else
value = WScript.Arguments(0)
key = "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters"
ValueName = "srvcomment"
reg.SetStringValue HKLM, key, ValueName, value
End if
‎10-01-2015 06:31 PM
‎10-01-2015 05:15 PM
‎09-30-2015 11:52 AM
‎09-24-2015 06:44 PM
‎04-17-2015 11:16 AM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now