Globalquest
asked on
How to querry server for license information using slmgr.vbs
We deployed some 2008 servers in the past with the wrong license and now some of them are losing their activation. I can use the slmgr.vbs script to capture individual server status but need to find a way to query all my servers. there are probably a couple hundred.
I used the command
cscript slmgr.vbs computername -xpr
output:
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
The machine is permanently activated.
How can I use the script to query all my 2008 servers an dump the results to it's own result file? example: computername.txt
(I have a text file named computers.txt with all of them listed)
I used the command
cscript slmgr.vbs computername -xpr
output:
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
The machine is permanently activated.
How can I use the script to query all my 2008 servers an dump the results to it's own result file? example: computername.txt
(I have a text file named computers.txt with all of them listed)
ASKER
I can run the command
cscript slmgr.vbs computername -xpr >c:\computername.txt
And that will give me the the desired results for that specific computer in that file.
What I really need is a way to scan multiple servers listed in either a text or csv file and dump the results into a text file for each server scanned.
I've tried editing a copy of slmgr.vbs with no luck. Of course, I am not a scripter.
cscript slmgr.vbs computername -xpr >c:\computername.txt
And that will give me the the desired results for that specific computer in that file.
What I really need is a way to scan multiple servers listed in either a text or csv file and dump the results into a text file for each server scanned.
I've tried editing a copy of slmgr.vbs with no luck. Of course, I am not a scripter.
you could use for %host% in contents from a file:
Example: http://www.tech-recipes.com/rx/363/processing-the-contents-of-a-text-file-using-for-loop/
Example: http://www.tech-recipes.com/rx/363/processing-the-contents-of-a-text-file-using-for-loop/
FOR /f %a in (‘complist.txt’) do echo Computer: %a
replace the echo with the line you have and make sure to change the redirect (>) to append using (>>)
ASKER
Ok here is the command that has so far worked
FOR /f %a in (d:\ncs\act\servers.txt) do cscript slmgr.vbs %a -xpr >d:\ncs\act\%a.txt
It queries the server and dumps to it's own text file. This is helpful because the output of the vbs script does not echo the server name.
FOR /f %a in (d:\ncs\act\servers.txt) do cscript slmgr.vbs %a -xpr >d:\ncs\act\%a.txt
It queries the server and dumps to it's own text file. This is helpful because the output of the vbs script does not echo the server name.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try adding:
> filename.txt
On the end, it should the output to a file.
Open in new window