#135036 - 2005-03-08 09:19 PM
Generate html report on free space - servers
|
Styles
Fresh Scripter
Registered: 2005-02-22
Posts: 12
|
I want to create a script that parses a log file (\\server\drive) and reports the total drive space, used space and free space. I'd like to mail the resulting html file in the script, but can use blat instead.
|
Top
|
|
|
|
#135038 - 2005-03-08 09:44 PM
Re: Generate html report on free space - servers
|
Styles
Fresh Scripter
Registered: 2005-02-22
Posts: 12
|
That looks a little overkill for the information I'm trying to gather. I just need to collect the info and generate a report on that info.
|
Top
|
|
|
|
#135040 - 2005-03-08 10:28 PM
Re: Generate html report on free space - servers
|
Styles
Fresh Scripter
Registered: 2005-02-22
Posts: 12
|
Agreed. No harm meant in my reply. I've been looking over the code.
|
Top
|
|
|
|
#135042 - 2005-03-11 06:21 PM
Re: Generate html report on free space - servers
|
Styles
Fresh Scripter
Registered: 2005-02-22
Posts: 12
|
HELP!
Here's what I came up with:
Code:
;Variables $ServerFile = "C:\admin\Servers.txt"
;-------Information $nul = Open(1,"$ServerFile") $server = ReadLine(1) While $server <> "EndList"
$ = RedirectOutput ("C:\admin\AvailDiskSpace.txt") $WMI = GetObject("winmgmts:\\" + @WKSTA + "\root\cimv2") $HardDrives = $WMI.ExecQuery("Select * From Win32_LogicalDisk Where DriveType=3") For Each $Drive in $HardDrives ? " Drive Letter: " $Drive.Name ? " Drive Space: " $Drive.Size ? " Drive Free Space: " $Drive.FreeSpace ? Next
I have two problems with this (1) the script does not read the text file I've created with the servername and (2) the script runs forever.
|
Top
|
|
|
|
#135043 - 2005-03-11 06:33 PM
Re: Generate html report on free space - servers
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Think you were missing some odds and ends, back at you ...
Code:
break on
$ServerFile = "C:\admin\Servers.txt"
;-------Information
$ = RedirectOutput ("C:\admin\AvailDiskSpace.txt")
$nul = Open(1,"$ServerFile")
$server = ReadLine(1)
while $server <> "EndList"
$WMI = GetObject("winmgmts:\\" + $server + "\root\cimv2")
$HardDrives = $WMI.ExecQuery("Select * From Win32_LogicalDisk Where DriveType=3")
For Each $Drive in $HardDrives ? " Drive Letter: " $Drive.Name ? " Drive Space: " $Drive.Size ? " Drive Free Space: " $Drive.FreeSpace ? Next
$server = ReadLine(1)
Loop
btw - dont "need" the have an EOF delimiter in your file (endlist), there are other ways to detect EOF.
|
Top
|
|
|
|
#135044 - 2005-03-11 08:34 PM
Re: Generate html report on free space - servers
|
Styles
Fresh Scripter
Registered: 2005-02-22
Posts: 12
|
I'm not sure what I'm missing, but the script now outputs Select * From Win32_LogicalDisk Where DriveType=3 over and over again until I hit Ctrl+C. I changed the end Loop to Exit and the script ends, but only reads one line of the servers.txt file.
|
Top
|
|
|
|
#135046 - 2005-03-12 02:33 PM
Re: Generate html report on free space - servers
|
Styles
Fresh Scripter
Registered: 2005-02-22
Posts: 12
|
That returns a 0 in the output file. Yes WMI in installed on the servers.
|
Top
|
|
|
|
#135055 - 2005-03-14 01:49 AM
Re: Generate html report on free space - servers
|
Styles
Fresh Scripter
Registered: 2005-02-22
Posts: 12
|
Thanks for the help.
I commented out all lines and re-ran the script one line at a time. The completed normally, but only reported the disk space on the first server in servers.txt
Using $WMI = GetObject(“winmgmts\\” + $server + “\root\cimv2”) work locally when I substitute the servername in quotes, i.e. “server01”.
Most servers in my domain have hyphens.
I’m Domain Admin. If the script is executed from my system – it should run OK on all systems in the domain.
I’ll post the code and servers.txt later today.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 369 anonymous users online.
|
|
|