Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I wish to populate the local machine description (overwrite if already present) with the Model of the computer. Is there some sort of script that can perform this task for me? I have found a site that has some code but they dont have a solution. i have very little knowledge of vb script. but if there is anyway of doing this that would be great.

Thanks

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Assuming your looking to change the computer description on the local machine itself, and not in Active Directory - you could do the following with Powershell (note: you'll need powershell on your XP clients).

$computer=get-wmiobject win32_computersystem
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters" -name "srvcomment" -value $computer.model

I looked for more elegant methods to update the computer description, but none of them actually worked. Updating the registry entry appeared to be the easiest method.

Assuming powershell doesn't work, you may want to look into a scripting language called AutoIT. AutoIt can compile everything into a self contained executable and eliminate client dependancies.

share|improve this answer
    
It's set programatically using net config server /srvcomment:"Testing". I'd love a way to read it from code though without having to poke at the registry. –  Nicholas Wilson Aug 21 '13 at 14:36
add comment

Standing on the shoulders of the excellent answer by CurtM, I have a non-powershell approach. Call this script from a logon script:

setmodel.cmd

@for /f " skip=1 tokens=1 delims=^|" %%a in ('wmic.exe path win32_computersystem get model' ) do set model=%%a 

@reg add HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters /v srvcomment /t reg_sz /d "%model%" /f

With minor modifications, you can process a list of machines in the domain:

setmodel_r.cmd

@for /f " skip=1 tokens=1 delims=^|" %%i in ('wmic.exe /node:%1 path win32_computersystem get model' ) do set model=%%i

@reg add \\%1\HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters /v srvcomment /t reg_sz /d "%model%" /f

Get a list of machines in the domain using dsquery.exe. Pipe the output to setmodel_r.cmd and you should have your model set as the description. From a command prompt, issue the command:

for /f %b in ('dsquery * domainroot -filter "(objectCategory=computer)" -attr name') do call setmodel_r.cmd %b

But, you may want to test the setmodel_r.cmd before running it against your entire domain-

for /f %b in (testcomputers.txt) do call setmodel_r.cmd %b

where testcomputers.txt contains several machine names, each on a new line.

You should play with these until you become comfortable with what they do.

Rob

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.