gathering drive information - command line

  • Thread starter Thread starter steven
  • Start date Start date
S

steven

I need a way to gather disk information from command
line,, I just need local logical drive letters captured in
an aschii file, comma delimited,, in the following format
servername,C,D,E,F
 
steven said:
I need a way to gather disk information from command
line,, I just need local logical drive letters captured in
an aschii file, comma delimited,, in the following format
servername,C,D,E,F

Hello Stven,
with the free psinfo out of pstools from www.sysinternals.com
the following batch will do for all servers in the var SrvList and
their *Fixed* disks. This requires your account has the rights on the
remote servers.

If you want cd-rom drive letters too, you should
change: find "Fixed"
to : findstr "Fixed CD-ROM"


@echo off & setlocal EnableExtensions EnableDelayedExpansion
set SrvList=Iterno Mars
for %%A in (%SrvList%) do (
set DrvInf=%%A
echo/Server: [!DrvInf!]
for /F "tokens=1 delims=:" %%B in ('psinfo \\!DrvInf! -d^|find "Fixed"') do (
set d=%%B
set DrvInf=!DrvInf!,!d:~-1!
)
echo/!DrvInf!
REM echo/!DrvInf!>testfile.txt
)

HTH
 
-----Original Message-----
steven said:
I need a way to gather disk information from command
line,, I just need local logical drive letters captured in
an aschii file, comma delimited,, in the following format
servername,C,D,E,F

Hello Stven,
with the free psinfo out of pstools from www.sysinternals.com
the following batch will do for all servers in the var SrvList and
their *Fixed* disks. This requires your account has the rights on the
remote servers.

If you want cd-rom drive letters too, you should
change: find "Fixed"
to : findstr "Fixed CD-ROM"


@echo off & setlocal EnableExtensions EnableDelayedExpansion
set SrvList=Iterno Mars
for %%A in (%SrvList%) do (
set DrvInf=%%A
echo/Server: [!DrvInf!]
for /F "tokens=1 delims=:" %%B in ('psinfo \\!DrvInf! - d^|find "Fixed"') do (
set d=%%B
set DrvInf=!DrvInf!,!d:~-1!
)
echo/!DrvInf!
REM echo/!DrvInf!>testfile.txt
)

HTH
--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
.
Mathew,, thanks,, can you tell me what some of the
variables are so that I can customize,,srvinfo takes
hostnames? are they comma delimited,, how do I change the
location of the txtfile?
 
This are computer names at my location, simply insert your own.
You could also use a plain vanilla textfile in every line a name.
In that case the following line has to be changed:
for /f "tokens=*" %%A in (yourfilename) do (
for %%A in (%SrvList%) do (
set DrvInf=%%A
echo/Server: [!DrvInf!]
for /F "tokens=1 delims=:" %%B in ('psinfo \\!DrvInf! -d^|find "Fixed"') do (
set d=%%B
set DrvInf=!DrvInf!,!d:~-1!
)
echo/!DrvInf!
REM echo/!DrvInf!>testfile.txt
)
To really write to a file, remove the REM and place
your wished filename behind a doubles >> to append to that file

echo/!DrvInf! >>C:\yourpath\yourfile.tyt

variables are so that I can customize,,srvinfo takes
hostnames? are they comma delimited,, how do I change the
location of the txtfile?

Matthias, please.
Look at the normal output of "psinfo -d" at the command line.
The find or findstr removes all unrelevant information.
The for command uses the colon via "delims=:" to split the
resulting lines at the colon and only uses the first part as
advised through "tokens=1". The Var %%B thus contains " x"
which is shortened to the last char and appended to the
var DrvInf. The exclamation marks instead of percent signs
are necessary for delayed expansion. For help on the used
commands enter in a comd window:

setlocal /?
for /?
set /?

This is the sample output at my location with only Fixed:

Server: [Iterno]
Iterno,C,E
Server: [Mars]
Mars,C,D,E,F

HTH
 
Back
Top