1) I need to first check the disk space.
2) then check if the free space on each drive is greater than 15% of the
total disk space(which is the threshold value) and notify the user.
3) then shrink the databases.
I have written the following VBSCript, but it is not serving the purpose.
Request you to please provide me with the correct inputs/script.
-------------------------------------------------------------------------------------
Code: VBScript
Set iFSO = CreateObject("Scripting.FilesyStemObject")
Set oFSO = CreateObject("Scripting.FilesyStemObject")
InputFile="Diskspace.txt"
Outputfile="Diskspacelist.csv"
Set ofile = ofso.createTextFile(OutputFile)
Set ifile = ifSO.OpenTextFile(inputfile)
Const GBCONVERSION= 1048576000
ofile.writeline "Server,Drive,Disk Size,FreeSpace"
Do until ifile.AtEndOfLine
Server = ifile.ReadLine
Set objWMIService = GetObject("winmgmts://" & Server)
Set colLogicalDisk = objWMIService.InstancesOf("Win32_LogicalDisk")
For Each objLogicalDisk In colLogicalDisk
if objLogicalDisk.drivetype=3 then
ofile.writeline Server & "," & objLogicalDisk.DeviceID &_
"," & FormatNumber(objLogicalDisk.size/GBCONVERSION,2) & "GB, " &_
FormatNumber(objLogicalDisk.freespace/GBCONVERSION,2) & "GB, "
end if
Next
Loop
iThreshold=(15/100)*(size)
iSize=freespace
If Int(iSize) < Int(iThreshold) Then
'free space is less than the threshold so generate an alert
wscript.Echo "Alert!"
strDescription=objLogicalDisk.freespace & " is less than the specified threshold of " &_
FormatNumber(iThreshold,2,,True) & " GB. Free space is " &_
FormatNumber(iSize,2,,True) & " GB"
wscript.echo strDescription
Else
'folder size is OK
WScript.Echo "The size of " &freespace & " (" & iSize &_
") is at least the threshold of " & iThreshold
End If
Thanks a lot in advance.
Marconi.

