cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Michael_V
Champion Sweeper III

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 REPLIES 10
jacobsenm
Engaged Sweeper III
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
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.
alar0n
Engaged Sweeper
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.


Hello!
When I run this script I get an error:
String: 2
Symbol: 1
vbscript index out of range
800A0009

Tell me please what is the problem?
HammettMike
Engaged Sweeper III
Oddly enough, I just found this already on the server:

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


I don't know crap about code to know if it's substantially different other than being more lines.
PeterJG
Champion Sweeper II
Mike,

the one I posted is for ACTION, the other one might be for deployment ..
PeterJG
Champion Sweeper II
Set WshNetwork = WScript.CreateObject("WScript.Network")

strComputer = Wscript.Arguments.Item(0)
strDescription = Inputbox("Enter Description:")

Set Obj= GetObject("winmgmts:\\" & strComputer).InstancesOf("Win32_OperatingSystem")
For Each x In Obj
x.Description = strDescription
x.Put_
Next

WScript.Quit
jacobsenm
Engaged Sweeper III
I am interested too.
Where is the "CmpDesc.vbs" script ?

Thank you.

HammettMike
Engaged Sweeper III
Where's the VBS to download?
Susan_A
Lansweeper Alumni
You could pull the currently logged on user from the client machine itself or (if hosted in SQL Server) from the Lansweeper database. The latter should be fairly accurate if you deploy after scanning. We can't really provide assistance for building or modifying specific deployment packages though. You will need to do some research online to find the steps you need.