Link to home
Start Free TrialLog in
Avatar of bnorrisatnortechsolutions
bnorrisatnortechsolutions

asked on

System Information Script

I am looking for a script that I can run on mulitple servers and capture the following:

System Name
CPU Info
Memory
Drive Info - Size - Free - Used

After capturing it I would like for this information be written to a .txt file.

I know trhat I can use SRVINFO from the Resource Kit, but that returns entirely too much information.
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Get the pstools from sysinternals (kinda part of Microsoft). One of those can do it. Don't remember the name ATM
Here is a very simplistic batch file:

Note that "/format:csv" does may not work on W7.

@ECHO OFF
SET Output=Output.txt
wmic logicaldisk where drivetype=3 get Name,Size,FreeSpace /format:csv>%Output%
wmic os get BuildNumber, BuildType, Version /format:csv>>%Output%
wmic cpu get Name>>%Output%
Avatar of Bill Prew
Bill Prew

Do you want to run a script on a single central computer and have it query each of the servers remotely, or are you looking for something that you can run on each server locally.

~bp
Avatar of bnorrisatnortechsolutions

ASKER

I am looknig for something that I can put a list of server names in and have the script run against that and return it's results to a txt file.
Here a modified version of my idea.

It is most likely "challanged" but I'm to tired to unbug it.

Cheers,
Rene

PS: hey ~bp

@ECHO OFF

SET Server.1=DomainController1
SET Server.2=webserver
SET Server.3=mysqlserver

FOR /F "tokens=2 delims==" %%A IN ('SET Server.') DO (
	wmic /node:%%A logicaldisk where drivetype=3 get Name,Size,FreeSpace /format:csv>"%%A.txt"
	wmic /node:%%A os get BuildNumber, BuildType, Version /format:csv>>"%%A.txt"
	wmic /node:%%A cpu get Name>>"%%A.txt"
)

Open in new window

Found my own solution.  Thank yuo all for your assistance.
And you don't want to share it with the rest of us?
Just preventing auto-close - I object until I know what the solution was.  I gave my time freely to this person and received no feedback to my comment, so I want to know what his solution was before I accept that I wasted my time.
Totally agree with leew
Sorry guys -

get-wmiobject -query "SELECT SystemName,Caption,VolumeName,Size,Freespace FROM win32_logicaldisk" -computer (get-content "C:\servers.txt") |

Select-Object SystemName,Caption,VolumeName,@{Name="Size(GB)"; Expression={"{0:N2}" -f ($_.Size/1GB)}},@{Name="Freespace(GB)"; Expression={"{0:N2}" -f ($_.Freespace/1GB)}}|

export-csv -path "C:\DiskSpace.csv" -NoTypeInformation

I am willing to offer some points for your time as I don't want you all to feel that I am not appreciative.  I just didn't know that I could if I didn't use your solution.  I again apologize.
 
So it looks like you used a PowerShell script and WMI... In a sense, what I suggested at first - "You should be able to use WMIC to obtain this information" - the difference being that WMIC is for the command line vs. powershell command line.

Just so we're clear.
@ModCorlEEone
It was me that stated "Totally agree with leew" not "bnorrisatnortechsolutions".

@All
I'm just curious why someone would hesitate to just split the totallity of the offered points. The solutions proposed are often elements of reflections to find the finnal solution and it does not cost him/her anything and demonstrats gratitude for the efforts of helping hands.

I'd like to have your input on this, cause I've seen this few times to often and I find this to be confusing.

Thanks,
Rene
@bnorrisatnortechsolutions

I just want to sure my question on my previous post not targetted to you. Maybe I'm missing something and in fact, It does cost something, like some points of the question originator or I don't know.

Cheers,
Rene