Re: Getting Drive Space properties on all servers in a domain



Thanks Guys,I would Try this and check if it works

Rgds
San

"marios.stavropoulos@xxxxxxxxx" wrote:

Hi Santosh

Try this script (save it with a wsf extension). It accepts as a command
line parameter the name of a text file that contains the computer names
(one name per line). I created it with ScriptAhead a tool that helps
you build scripts visually.

If you need something different let me know

Marios
-----------
www.softomotive.com
ScriptAhead: Windows Scripting without the hassle.




<?xml version="1.0"?>
<package>
<job>
<comment><![CDATA[
'*************************************************************************
' This script has been automatically generated by:
' ScriptAhead ver 1.0.0.368
'
' Script Name: FreeSpace.wsf
' Author: marios
' Date: 30/6/2006
'*************************************************************************

]]></comment>
<runtime>
<unnamed name="FileName" helpstring="The name of the file that
contains the server names" more="False" required="1" />
</runtime>
<script language="VBScript"><![CDATA[

On Error Resume Next


Dim v_FileName

CheckCommandLineArguments

Err.Clear
ReDim v_ComputerNames(-1)
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile=objFSO.OpenTextFile(v_FileName,1)
If Err.Number<>0 Then ReportRuntimeError 1, _
"Error occured while opening file " & v_FileName
i=0
Do Until objFile.AtEndOfStream
ReDim Preserve v_ComputerNames(i)
v_ComputerNames(i)=objFile.ReadLine
i=i+1
Loop
objFile.Close


For Each v_CurrentComputerName In v_ComputerNames

WScript.Echo "Computer " & v_CurrentComputerName & _
" has the following Drives:"

ReDim v_LogicalDiskDrives(-1)
Err.Clear
Set objWMI=GetSWbemServices(v_CurrentComputerName, _
"\root\cimv2", null)
If Err.Number<>0 Then ReportRuntimeError 4, _
"Error while trying to connect to WMI Service in computer " & _
v_CurrentComputerName
Set colLogicalDiskDrives=objWMI.ExecQuery(_
"SELECT * FROM Win32_LogicalDisk" + Replace(" WHERE DriveType=3", _
"\","\\"),,48)
AppendCollectionToArray colLogicalDiskDrives, v_LogicalDiskDrives

For Each objLogicalDiskDrive in v_LogicalDiskDrives
WScript.Echo objLogicalDiskDrive.Name & " Total Size: " _
& (objLogicalDiskDrive.Size / 1000000000) & " GB, Free Space: " & _
(objLogicalDiskDrive.FreeSpace / 1000000000) & " GB (" & (( _
objLogicalDiskDrive.FreeSpace / objLogicalDiskDrive.Size) * 100) & _
"% Free)"
Next

WScript.Echo

Next


Sub CheckCommandLineArguments
Dim errorInArguments
errorInArguments=False


If WScript.Arguments.Unnamed.Count=1 Then
v_FileName=WScript.Arguments.Unnamed(0)
Else
errorInArguments=True
End If

If errorInArguments Then
WScript.Arguments.ShowUsage
WScript.Quit
End If
End Sub


Function GetSWbemServices (strComputerName, strNamespace, _
arrPrivileges)
Set objSWbemLocator=CreateObject ("WbemScripting.SWbemLocator")
Set objSWbemServices=objSWbemLocator.ConnectServer( _
strComputerName, strNamespace)
objSWbemServices.Security_.ImpersonationLevel=3

If Not IsNull(arrPrivileges) Then
For Each strPrivilege In arrPrivileges
objSWbemServices.Security_.Privileges.AddAsString _
strPrivilege,True
Next
End If

Set GetSWbemServices=objSWbemServices
End Function



Sub AppendCollectionToArray (col, arr)
For Each item In col
ReDim Preserve arr(UBound(arr)+1)
Set arr(UBound(arr))=item
Next
End Sub



Sub ReportRuntimeError (taskNumber, errorMessage)
WScript.Echo "ScriptAheadRuntimeError Runtime error in task #" _
& taskNumber & ": " & errorMessage & vbCrLf _
& "VBScript description for error: " & _
Err.Description & " (" & Err.Number & ")"
WScript.Quit
End Sub


]]></script>
</job>
</package>

Santosh wrote:
Hi Guys,

If anyone could help me getting a script to get the Drive properties ie
space usage in C, D drive of all the servers in a domain.

Thanks
Santosh


.



Relevant Pages

  • Re: Detecting is hyperthreading is enabled with WMI?
    ... It is too bad that WMI does not give this info. ... have to be done to the script. ... Public Sub DisplayProcessorInfo ... dim ProcessorSet, Processor ...
    (microsoft.public.windowsxp.wmi)
  • Re: Logon Drive Mapping script
    ... >> This script will remap to the correct drive. ... > But a workaround is to add the sub-routine AdjustDriveDescription ... > drives, make a callout to the sub like this: ... > Sub AdjustDriveDescription ...
    (microsoft.public.windows.server.scripting)
  • Cant make this page work
    ... I can't make this script work properly. ... The script at the bottom of the html page ... Does someone have a perl ... sub output_trace_headers { ...
    (comp.lang.javascript)
  • Re: Maybe I should try a different approach
    ... entire time my script is running, then have it close when my script is done and maybe have some dots keep adding to the text message until the script is fully completed? ... ' The "Three Ugly Hack" Script, ... Sub oATO_vbTimerEvent' timer event handler... ... Public Property Let Left ...
    (microsoft.public.scripting.vbscript)
  • Re: Win32_Product doesnt list all installed Applications
    ... 'Must have ADSI and WMI installed on PC running script. ... CONST ForReading = 1 ... Sub Connect ... strHTML = "Smoke'm if you Got'em" ...
    (microsoft.public.windows.server.scripting)