Re: Getting Drive Space properties on all servers in a domain
- From: Santosh <Santosh@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 5 Jul 2006 01:50:01 -0700
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
- Prev by Date: Re: copy file with date prefix
- Next by Date: Mirror status
- Previous by thread: Re: copy file with date prefix
- Next by thread: Mirror status
- Index(es):
Relevant Pages
|