Thanks for the help with the script. I have one question - where do i replace the code ih the two sections above? I noticed the script that I posted did not post as expected. It looks like a few function sections got repeated. I'll try posting again.
Code:
Shell "%COMSPEC% /e:1024 /c c:\windows\netview.exe /NTS /BDC /PDC >c:\admin\kix2010_451\servers.txt" If @error<>0 ? "Netview is not found !" ? ? " You have to download netview at (http://www.optimumx.com/download/#NetView)" ? " and place it in this script directory." Quit EndIf
$line="" If Open(3, "c:\admin\kix2010_451\servers.txt") = 0 $x = ReadLine(3) While @ERROR = 0 If $x<>"" $pos=InStr($x," ") $xf=Left($x,$pos-1) If InStr($x,"\\")<>0 $xf=Right($xf,Len($xf)-2) $line=$line+"~~"+$xf EndIf EndIf $x = ReadLine(3) Loop $=Close (3)
EndIf $servarray=Split($line,"~~") debhtml() For Each $strComputer in $servarray If $strComputer<>"" ? "In progress for "+$strComputer+" ..." $objWMIService = GetObject("winmgmts:\\"+$strComputer+"\root\cimv2") If @ERROR=0 breakl() $DiskSet = $objWMIService.ExecQuery("select * from Win32_LogicalDisk where DriveType=3") $co=0 For Each $Disk In $DiskSet $co=$co+1 $dname=$Disk.Name $percentfree=Round(DISKSPACE($strComputer,$dname,5)) $percentused=100-$percentfree $rest=$percentfree-5 $free-GetFreeSpace($WS,$Drive) html($strComputer,$dname,$percentused,$rest,$free) Next ftabl() Else ? $strcomputer+" WMI not installed." breakl() offline($strcomputer) ftabl() EndIf
"+@CRLF $x = $x + ""+@CRLF $x = $x + "Unfortunately the non Windows servers could not be query "+@CRLF $x = $x + "and report the line 'No WMI or server offline' : (
EndFunction ;************************************************* ;FUNCTION DiskSpace ; ;ACTION returns the available disk space on a drive ; ;AUTHOR Jens Meyer (sealeopard@usa.net) ; ;CONTRIBUTORS NTDOC, Radimus, kholm ; ;VERSION 1.4 (added PetaByte, Percentage as unit sizes) ; 1.3 (shortened code, included UNCs as valid input) ; 1.2 (added optional drive and optional units) ; 1.1 ; ;DATE CREATED 2001/12/18 ; ;DATE MODIFIED 2003/07/06 ; ;KIXTART 4.21 ; ;SYNTAX DISKSPACE([DRIVE, FORMAT]) ; ;PARAMETERS DRIVE ; optional driveletter, directory, or UNC (defaults to system drive) ; ; FORMAT ; optional parameter indicating the units to be used when returning the ; available disk space ; 0 = KB (KiloByte, default) ; 1 = MB (MegaByte) ; 2 = GB (GigaByte) ; 3 = TB (TeraByte) ; 4 = PB (PetaByte) ; 5 = % (percentage total diskspace, does not support UNCs) ; ;RETURNS available diskspace ; ;REMARKS none ; ;DEPENDENCIES WMI (only for FORMAT = 5) ; ;EXAMPLE $rc=DISKSPACE() ; ; Function diskspace($computer,optional $drive, optional $format) Dim $objWMIService, $sWQL, $colDrives, $objDrive If NOT $drive $drive='%WINDIR%' EndIf $format=Val($format) If $format<5 $format=IIf($format=1,1024,IIf($format=2,1024.0*1024,IIf($format=3,1024.0*1024*1024,IIf($format=4,1024.0*1024*1024*1024,1)))) $diskspace=CDbl(GetDiskSpace($drive))/$format Else $objWMIService=GetObject('winmgmts:{impersonationLevel=impersonate}!\\'+$computer+'\root\cimv2') $sWQL = "SELECT Size, FreeSpace FROM Win32_LogicalDisk WHERE Name='"+Left($drive,2)+"'" $colDrives=$objWMIService.ExecQuery($sWQL) For Each $objDrive in $colDrives $diskspace=CDbl($objDrive.FreeSpace)/CDbl($objDrive.Size)*100 Next EndIf Exit @ERROR EndFunction
;Function: ; GetFreeSpace() ; ;Author: ; Kholm ; ;Version: ; 1.0 (17th of september 2003) ; ;Action: Returns available space on diskdrives on remote workstations (where the server service is NOT started) ; ;Syntax GetFreeSpace($WS,$Drive) ; ;Parameters: ; - $WS = Name of remote workstation ; - $Drive = Driveletter for drive to be checked ; ;Returns: Free space on selected ws/drive ; ;Dependencies: WMI ; ;Remarks: ; OBSERVE: You should use the KiXtart function: GetDiskSpace('\\' + $Computer + '\' + $Drive + '$$') ; If the server service is startet on the workstation you want to check, ; ;Example: ; $Free = GetFreeSpace('WS02','C') ; 'Free space on drive C: on workstation WS02 is: ' + $Free
Function GetFreeSpace($Computer,$Drive) Dim $oComputer,$cItems,$oItem $oComputer = GetObject("winmgmts:\\" + $Computer + "\root\cimv2") $cItems = $oComputer.ExecQuery("Select * from Win32_LogicalDisk where DeviceID='" + $Drive + ":'") For Each $oItem In $cItems $GetFreeSpace = 0.0009765625 * $oItem.FreeSpace Next EndFunction
;Function GetFreeSpace($Computer,$Drive) ; Dim $oComputer,$cItems,$oItem ; $oComputer = GetObject("winmgmts:\\" + $Computer + "\root\cimv2") ; $cItems = $oComputer.ExecQuery("Select * from Win32_LogicalDisk where DeviceID='$Drive:'") ; For Each $oItem In $cItems ; $GetFreeSpace = 0.0009765625 * $oItem.FreeSpace ; Next ;EndFunction