Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change computer description via LanSweeper

Engaged Sweeper II

I've been tasked with changing the computer description on our Windows servers. (In system settings)
We do have a description current that gets fed into LanSweeper.
The task is to prepend either a TEST or PROD at the beginning of each description on each server.

Can this be done with LanSweeper?

I did attempt to change the computer description on one computer in LS by editing the asset and changing the description field, but it does not appear to change anything on the actual server.

Thank you!

Engaged Sweeper III
Create the following asset action:

cscript {actionpath}changeAdCompDesc.vbs {computer}

Here is the changeAdCompDesc.vbs - be sure to replace "dc=your-domain,dc=com" with your own DC

' 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=your-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

Honored Sweeper
Could you not deploy a package like below.

net config server /srvcomment:"%COMPUTERNAME%"

We currently don't update the computer description but we label the C drive with the computer name using the following.


We also have a script which writes the computer info into AD.

' This script changes a computer's description as well as registers it in active directory with the serial number and last logged in user. 
' If you want this to update automatically, make this a logon script in group policy.

On Error Resume Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colsystemenclosure = objwmiservice.execquery("Select * from Win32_SystemEnclosure")
' Get Serial number
For Each objcomputer In colsystemenclosure
serialnumber = Trim(objcomputer.serialnumber)
'get AD user
Set adsinfo = CreateObject("adsysteminfo")
Set adcomputer = GetObject("LDAP://" & adsinfo.ComputerName)
Set aduser = GetObject("LDAP://" & adsinfo.UserName)
username =

strcomputer = wshnetwork.computername

Set objwmiservice = GetObject("winmgmts:{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")
Set colcomputer = objwmiservice.execquery("Select * from Win32_computersystem")
Set colcomputerdisk = objwmiservice.execquery("Select * from Win32_diskdrive")
Set coloperatingsystem = objwmiservice.execquery("Select * from Win32_OperatingSystem")
Set colsystemenclosure = objwmiservice.execquery("Select * from Win32_SystemEnclosure")
Set colmacid = objWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID = 'Local Area Connection'")

'get model
For Each objcomputer In colcomputer
cpumanufacturer = objcomputer.manufacturer
cpumodel = Trim(objcomputer.model)

' Get OS version
For Each objcomputer In coloperatingsystem
servicepack = objcomputer.servicepackmajorversion
osver =
osver1 = Mid( osver, 18,3)

'Pull the machine description. This can be formatted however you want. We use a "RM:" then a five letter description filled in with leading zeros.

desc = GetDesc()

'sets the information in AD
'adcomputer.put "description", "LU: " & username & ", PC: " & desc & ", OS: " & osver1 & ", Mod: " & cpumodel & ", SN: " & ucase(serialnumber)
'adcomputer.put "description", "LU: " & username & ", OS: " & osver1 & ", Mod: " & cpumodel & ", SN: " & ucase(serialnumber)
adcomputer.put "description", "" & username & ", OS: " & osver1 & ", Mod: " & cpumodel & ", SN: " & ucase(serialnumber)
'This bit sets the last logged on user as the "phonetic display name" in AD. It makes it easy to figure out what computer someone is talking about just by adding a column.
'adcomputer.put "msDS-PhoneticDisplayName", "Last User: " & username

Function GetDesc()

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT Description FROM Win32_OperatingSystem")
For Each objItem in colItems
desc = objItem.Description
GetDesc = desc

End Function

Function GetUser()

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
user = objComputer.UserName

GetUser = user
End Function

Engaged Sweeper III
you can add an asset action like this: "cmd.exe /c {actionpath}comp_desc.vbs {smartname}"
This will start the following script in the defined directory (actionpath) and ask for a computer description:

Set WshNetwork = WScript.CreateObject("WScript.Network")

strComputer = Wscript.Arguments.Item(0)
strDescription = Inputbox("Geben Sie die Beschreibung des PC's ein:")

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