Whilst I am in the process of writing these scripts to make my job easier I learnt that there is such a thing as information overload!
The disk space report is all very well but, what if you only wanted to see the servers with disk running low on space, we set our thresholds typically at 20% as that should give us enough time to plan new disks if needed or address the problem for most servers.
So I started with a script that checked all the disks attached to servers listed in the text file and only reported back if they were under 20%. initially I had a problem when I used the < 20 command it still reported back with everything! what i needed to do was actually set it to < .2.
So I now had this script that would go away and check all the servers and report back to a test.txt file.
If I automate this to run every day and I want it to report to a share on the network and the file names are all the same then I will only have the one file as it would get over written every day, so the 2nd revision of the script contained the date function so it would be a unique filename for that specific date.
I then thought, what if you didn’t like the name test.txt, its not a very good name for the output file so I decided to set it so that you only have to change the name and path once in the script rather than every place it is referenced to further down.
I also set a completed message in there so it would tell you that it had completed, would give you the file path and then ask if you would like to open the file or not. if you say yes to opening the file it will launch Excel and open in there as the file is a Tab delimited text file.
The next revision of the script I set the percentage up with the file name so the output file would contain it too. to get the free percent I just divided that number by 100.
percentage = 20
repfilename = "DiskSpaceLessThan"
repdate = "-" & (GetDate (Now, ""))
reppath = "C:\output\"
repext = ".txt"
FreePercent = percentage / 100
myfile = reppath & repfilename & percentage & repdate & repext
So if you wanted to change the percentage all you would need to do would be to change it where funnily enough it says percentage = 20!
I thought that if you run this script manually (by dragging the list of servers onto the VBScript file) you may want to specify the threshold, so I change the percent = 20 line to an input box.:
percentage=InputBox("Please enter the threshold eg 20 for 20%:")
repfilename = "DiskSpaceLessThan"
repdate = "-" & (GetDate (Now, ""))
reppath = "C:\output\"
repext = ".txt"
FreePercent = percentage / 100
myfile = reppath & repfilename & percentage & repdate & repext
I thought as I was on a roll this morning with the scripting I will create a basic script that will check the space for a specified server and report to the text file and open up. I get asked on a regular basis on how our exchange server is doing for free space, so this will save me either logging onto the server to check, and or looking through log files that had been sent that morning. The script would give me the free space at that point in time.
I have put the three scripts into a zip file for download: