VBSCRIPT To find the free space and total space of a group of system
This script will read the INPUT file from the loacation and will find out the free space and total space of teh drives in the system and store it in OUTPUT.txt file.
The Input file should be having the server names one servername per line (line delimted).
Copy the file and save it as .vbs file and excute it after making sure that the INPUT.txt file is there. Also these servers needs to be reachable adn WMI should be avilable remotely. In short you should be having admin rights :)
==================================================================
Option Explicit
const strReport = "c:\OUTPUT.txt"
const sFile = "C:\INPUT.txt"
Dim objWMIService, objItem, colItems
Dim strDriveType, strDiskSize, txt
Dim oFSO, oFile, sText,strComputer
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim objFSO,objTextFile
Set objFSO = createobject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(strReport)
If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
Do While Not oFile.AtEndOfStream
sText = oFile.ReadLine
If Trim(sText) <> "" Then
strComputer=sText
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3")
txt = sText & vbtab & "Drive" & vbtab & "Size" & vbtab & "Used" & vbtab & "Free" & vbtab & "Free(%)" & vbcrlf
For Each objItem in colItems
DIM pctFreeSpace,strFreeSpace,strusedSpace
pctFreeSpace = INT((objItem.FreeSpace / objItem.Size) * 1000)/10
strDiskSize = Int(objItem.Size /1073741824) & "Gb"
strFreeSpace = Int(objItem.FreeSpace /1073741824) & "Gb"
strUsedSpace = Int((objItem.Size-objItem.FreeSpace)/1073741824) & "Gb"
txt = txt & vbtab & vbtab & objItem.Name & vbtab & strDiskSize & vbtab & strUsedSpace & vbTab & strFreeSpace & vbtab & pctFreeSpace & vbcrlf
Next
objTextFile.Write(txt)
End If
Loop
objTextFile.Close
oFile.Close
Else
WScript.Echo "The file was not there."
End If
=======================================================
Hope tha this information will be helpful
Sudheesh Narayanaswamy
Comments
Anonymous
January 01, 2003
The comment has been removedAnonymous
January 01, 2003
Thank You i had made the changes too in the script nowAnonymous
March 13, 2014
The comment has been removedAnonymous
April 17, 2014
The comment has been removedAnonymous
June 26, 2014
this script is really helpful to find disk space in servers.....Anonymous
June 26, 2014
can u please add the script to find the file size with the extension format. ( .docx size ..xlsx size etc)Anonymous
September 17, 2014
Its really a good script using it with few more addition thnxAnonymous
October 14, 2014
Hi, its not working properly could you please send the correct scriptAnonymous
December 09, 2014
It's WORK.
vijay, this link may help you http://www.makeuseof.com/tag/send-automated-emails-save-time-sendemail-windows-task-scheduler/Anonymous
July 06, 2015
if i want to check space folder of particular path then how to check that?Anonymous
August 05, 2015
Hi I am getting, error msg : the remote server does not exist or unavailableAnonymous
August 05, 2015
Hi, When I tried for systems in other domains I am getting, error msg : the remote server does not exist or unavailable,Anonymous
August 12, 2015
Good script but it is not retrieving all volumes how can i do this (example volumes mounted ones sql)Anonymous
February 22, 2016
The comment has been removed