Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drive Space Util

Status
Not open for further replies.

ic1frosty

Technical User
May 25, 2003
37
GB

Does any one know of a utility that can output drive capacities and free space on remote servers to a text file or excel worksheet.

Any help is much appreciated.
 
Write a VBScript and use WMI to query the remote machines. Post in the VBScript forum for a possible solution.

I hate all Uppercase... I don't want my groups to seem angry at me all the time! =)
- ColdFlame (vbscript forum)
 
I think is you look at the SysInternal suite it has BGInfo that should be able to handle that for you.
 
Here is a script i wrote that sends an email with a free space report to the specified email address using smtp.

I have it scheduled on a server to run a couple times a day.

I modified this to remove any personal information, but it should work fine. You need to change 4 variables near the top of the program to make it work how you would like.

Code:
locComputer = "."


'set the WMI service & shell
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & locComputer & "\root\cimv2")
Set WshShell = WScript.CreateObject("WScript.Shell")

Set WshNetwork = WScript.CreateObject("WScript.Network")

server = WshNetwork.ComputerName

'Only report drives with less than this percent free
LowSpaceThreshold = 0.15

'Only check drives bigger than this amount (in GB)
MinimumDiskSizeToCheck = 5

'Send email to this address
emailAddress = "user@company.com"

'SMTP server
smtpServer = 192.168.100.100

arrVolume = Array("ServerName/Volume1")

'Run script below for every entry in array
For Each strVolume In arrVolume
Set colDisks = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")


LowSpaceFound = 0

	For Each objDisk in colDisks
			'Change from Bytes to GB
			DiskSize=objDisk.Size/(1024*1024*1024)
			DiskFree=objDisk.FreeSpace/(1024*1024*1024)
			
				
			If DiskSize > MinimumDiskSize Then	
				If Not IsNull(DiskSize) Then 
						DiskSize = Round(DiskSize, 1)
				End If
				If Not IsNull(DiskFree) Then 
						DiskFree = Round(DiskFree, 1)
				End If
				
				PercentFree = Round (DiskFree/DiskSize, 2)

				
				If PercentFree  < LowSpaceThreshold Then
					LowSpaceFound = 1
					strText= strText & objDisk.DeviceID & " "& PercentFree*100 & "% Free" & vbCrLf & "   Total: " & DiskSize & " GB " & vbCrLf & "   Free: " & DiskFree & " GB " & vbCrLf & vbCrLf
				End If
		
			End If	
	Next
Next

strText = strText & vbCrLf  & "This report excludes drives whose Total Size is less than " & MinimumDiskSizeToCheck & "GB (CD/DVD Drives). It is scheduled to run on " & server & ". Check Control Panel-->Scheduled Tasks to delete or modify this job."




If LowSpaceFound > 0 Then
		Set objEmail = CreateObject("CDO.Message")
		objEmail.From = server & "_Free_Space_Notifier"
		objEmail.To = emailAddress
		
		objEmail.Subject = server & " - Drives with free space < " & LowSpaceThreshold * 100 & "%"
		objEmail.Textbody = strText
		objEmail.Configuration.Fields.Item _
		    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
		objEmail.Configuration.Fields.Item _
		    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = _
		        smtpServer
		objEmail.Configuration.Fields.Item _
		    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
		objEmail.Configuration.Fields.Update
		objEmail.Send
End If

Thanks,
Andrew

[medal] Hard work often pays off over time, but procrastination pays off right now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top