{"id":8,"date":"2008-03-24T16:35:11","date_gmt":"2008-03-24T20:35:11","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/?p=8"},"modified":"2018-03-11T21:54:30","modified_gmt":"2018-03-12T01:54:30","slug":"checking-admin-share-free-space-and-folder-space-usage","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2008\/03\/24\/checking-admin-share-free-space-and-folder-space-usage\/","title":{"rendered":"Checking admin share free space and folder space usage"},"content":{"rendered":"<p>The code to perform these two space checks is below, with the output file being generated in comma-delimited CSV format. When we use this, we need to first set a few configuration items in the first section.<\/p>\n<ul>\n<li><b>outputFile<\/b> : Enter the path and file name of the output report.<\/li>\n<li><b>i<\/b> : The number of items you wish to check; in the example, the number is 4 (2 drives and 2 folders)<\/li>\n<li><b>arrayList(x, y)<\/b> : These are the details of each drive\/folder you wish to check&#8230;<\/li>\n<\/ul>\n<p>The code is as follows:<\/p>\n<pre class=\"code\">option explicit\r\ndim outputFile, arrayList, fso, obj, fl, j, drivepath, driveName, status, msg\r\n'''''''Config''''''''''\r\n\r\n' Where do you want to output the results to?\r\noutputFile = \"checkSpace.log\"\r\n\r\n' How many drives do you want to check for free space?\r\nconst i = 4\r\nredim arrayList(i,5) 'Please do not touch this line.\r\n\r\n' List the server drives you want to check for free space or folders to check for space usage\r\n' Each set has 5 values:\r\n' a. D=drive, F=folder\r\n' b. server hostname\r\n' c. admin share drive letter (applicable for type D only)\r\n' d. warning level in gb\r\n' e. alarm level in gb\r\n' f. common name of this share\r\n\r\narrayList(0,0) = \"D\"\r\narrayList(0,1) = \"web1\"\r\narrayList(0,2) = \"c\"\r\narrayList(0,3) = 10\r\narrayList(0,4) = 5\r\narrayList(0,5) = \"Windows 2003 web server, C-drive\"\r\n\r\narrayList(1,0) = \"D\"\r\narrayList(1,1) = \"exch2\"\r\narrayList(1,2) = \"d\"\r\narrayList(1,3) = 200\r\narrayList(1,4) = 100\r\narrayList(1,5) = \"Windows 2003 Exchange server, D-drive\"\r\n\r\narrayList(2,0) = \"F\"\r\narrayList(2,1) = \"\\fileserverpublicfileShare1\"\r\narrayList(2,2) = \"\"\r\narrayList(2,3) = 1\r\narrayList(2,4) = 2\r\narrayList(2,5) = \"File share 1\"\r\n\r\narrayList(3,0) = \"F\"\r\narrayList(3,1) = \"\\fileserverpublicfileShare2\"\r\narrayList(3,2) = \"\"\r\narrayList(3,3) = 100\r\narrayList(3,4) = 200\r\narrayList(3,5) = \"File share 2\"\r\n\r\n'''''''End Config'''''''''\r\n\r\nset fso = CreateObject(\"Scripting.FileSystemObject\")\r\nset fl = fso.CreateTextFile(outputFile, true)\r\n\r\nfl.writeline(\"\"\"Item\"\",\"\"Status\"\",\"\"Message\"\"\")\r\n\r\nj = 0\r\ndo while j <= i-1\r\n\tif arrayList(j,0) = \"D\" then\r\n\t\tdrivepath = \"\\\\\" &#038; arrayList(j,1) &#038; \"\\\" &#038; arrayList(j,2) &#038; \"$\"\r\n\t\tset obj = fso.GetDrive(fso.GetDriveName(drivepath))\r\n\telseif arrayList(j,0) = \"F\" then\r\n\t\tdrivepath = arrayList(j,1)\r\n\t\tset obj = fso.GetFolder(drivepath)\r\n\telse\r\n\t\t' shouldn't really get in here...\r\n\tend if\r\n\t\t\r\n\tdriveName = arrayList(j,5)\r\n\t\r\n\tif arrayList(j,0) = \"D\" then\r\n\t\tif round(obj.FreeSpace\/1024\/1024\/1024) < arrayList(j,4) then\r\n\t\t\tstatus = \"alarm\"\r\n\t\t\tmsg = drivepath &#038; \" (\" &#038; driveName &#038; \") only has \" &#038; round(obj.FreeSpace\/1024\/1024\/1024) &#038; \"gb free\"\r\n\t\telse\r\n\t\t\tif round(obj.FreeSpace\/1024\/1024\/1024) < arrayList(j,3) then\r\n\t\t\t\tstatus = \"warning\"\r\n\t\t\t\tmsg = drivepath &#038; \" (\" &#038; driveName &#038; \") only has \" &#038; round(obj.FreeSpace\/1024\/1024\/1024) &#038; \"gb free\"\r\n\t\t\telse\r\n\t\t\t\tstatus = \"ok\"\r\n\t\t\t\tmsg = drivepath &#038; \" (\" &#038; driveName &#038; \") is ok with \" &#038; round(obj.FreeSpace\/1024\/1024\/1024) &#038; \"gb free\"\r\n\t\t\tend if\r\n\t\tend if\r\n\telseif arrayList(j,0) = \"F\" then\r\n\t\tif round(obj.size\/1024\/1024\/1024) > arrayList(j,4) then\r\n\t\t\tstatus = \"alarm\"\r\n\t\t\tmsg = drivepath & \" (\" & driveName & \") has reached \" & round(obj.size\/1024\/1024\/1024) & \"gb\"\r\n\t\telseif round(obj.size\/1024\/1024\/1024) > arrayList(j,3) then\r\n\t\t\tstatus = \"warning\"\r\n\t\t\tmsg = drivepath & \" (\" & driveName & \") has reached \" & round(obj.size\/1024\/1024\/1024) & \"gb\"\r\n\t\telse\r\n\t\t\tstatus = \"ok\"\r\n\t\t\tmsg = drivepath & \" (\" & driveName & \") is ok at \" & round(obj.size\/1024\/1024\/1024) & \"gb used\"\r\n\t\tend if\r\n\telse\r\n\t\tstatus = \"error\"\r\n\t\tmsg = \"Configuration error\"\r\n\tend if\r\n\t\r\n\tfl.writeline(\"\"\"\" & drivepath & \"\"\",\"\"\" & status & \"\"\",\"\"\" & msg & \"\"\"\")\r\n\t\r\n\tset obj = nothing\r\n\tj = j+1\r\nloop\r\n\r\nset fl=nothing\r\nset fso=nothing<\/pre>\n<p>The output CSV file should look something like this.<\/p>\n<pre class=\"code\">\"Item\",\"Status\",\"Message\"\r\n\"\\\\web1\\c$\",\"ok\",\"\\\\web1\\c$ (Windows 2003 web server, C-drive) is ok with 10gb free\"\r\n\"\\\\exch2\\c$\",\"alarm\",\"\\\\exch2\\c$ (Windows 2003 Exchange server, D-drive) only has 16gb free\"\r\n\"\\\\fileserver\\public\\fileShare1\",\"warning\",\"\\\\fileserver\\public\\fileShare1 (File share 1) has reached 2gb\"\r\n\"\\\\fileserver\\public\\fileShare2\",\"ok\",\"\\\\fileserver\\public\\fileShare2 (File sahre2) is ok at 91gb used\"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This VBScript code sample will help us set a foundation for an automated script to check how much free space is left on a Windows administrative share as well as how much space is used for any given shared folder.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,26],"tags":[],"class_list":["post-8","post","type-post","status-publish","format-standard","hentry","category-vbscript","category-windows"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":2,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions\/165"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}