Kaseya Community

Treesize Script to get disk usage on drive

  • Hi ,

    Can somebody share with me treesize script that provides the detail of disk usage on drives. Also I want the result of this script via email. Any help would be appreciated.

  • What kind of disk usage details are you looking for?  For instance, are you looking for per user storage?  Or just looking for free space, space used, etc?

    There are several different vb scripts you can find to do things like this.  You can use Kaseya to execute the script and then save the results to a .txt file which you then retrieve with Kaseya and e-mail.

    Here's a link to get you started: www.activexperts.com/.../drives

  • I need a simple script that would provide me the list of programs consuming space on a drive (particulary C:) and want this result to be sent as an email , any help would be appreciated because I am very much new to this scripting part and if you can send me the script that can be imported in the VSA that would be a great help.

  • See this thread (there are a couple in there) community.kaseya.com/.../93846.aspx

  • Script is working fine for me , only the result shows one error occured and I ma not sure what is that error , the only change that I ahve done with your script is add our email id to get the result ...this is what I recieved in email :-

    1 errors occurred.

    32202 mb, 113442 files, C:\

    32202 mb, 113442 files, 20662 dirs, 32202259610 bytes.

    17569 mb, 82194 files,  C:\Windows

    11209 mb, 56427 files,   C:\Windows\winsxs

    5123 mb,  3835 files,  C:\SWTOOLS

    3923 mb, 16409 files,  C:\Program Files (x86)

    3561 mb, 10149 files,  C:\Program Files

    2436 mb, 11229 files,   C:\Windows\System32

    1747 mb,  2483 files,   C:\SWTOOLS\DRIVERS

    1742 mb,  6335 files,   C:\Program Files\Microsoft Office

    1437 mb,   286 files,  C:\sounds

    1268 mb,   586 files,   C:\SWTOOLS\readyapps

    1219 mb,  2963 files,    C:\Program Files\Microsoft Office\Office15

    1201 mb,  4682 files,   C:\Windows\SysWOW64

    1190 mb,  5909 files,    C:\Windows\System32\DriverStore

    1186 mb,  5536 files,     C:\Windows\System32\DriverStore\FileRepository

    1087 mb,  2457 files,   C:\Windows\Microsoft.NET

  • I get the the nondescript error (and sometimes a warning instead) as well.  I don't know what causes it, I've tried to fix it.  I just ignore it.

  • But I am not getting the actual result of script also , as can be seen in screenshot the actual drive space used is 56.8 GB but script is showing around 32 Gb not sure from where it's picking up the result . Can you please help:-

    1 errors occurred.

    32305 mb, 113387 files, C:\

    32305 mb, 113387 files, 20677 dirs, 32305237586 bytes.

    17632 mb, 82078 files,  C:\Windows

    11209 mb, 56409 files,   C:\Windows\winsxs

    5123 mb,  3835 files,  C:\SWTOOLS

    3922 mb, 16416 files,  C:\Program Files (x86)

    3588 mb, 10201 files,  C:\Program Files

    2435 mb, 11222 files,   C:\Windows\System32

    1747 mb,  2483 files,   C:\SWTOOLS\DRIVERS

    1742 mb,  6335 files,   C:\Program Files\Microsoft Office

    1437 mb,   286 files,  C:\sounds

    1268 mb,   586 files,   C:\SWTOOLS\readyapps

    1219 mb,  2963 files,    C:\Program Files\Microsoft Office\Office15

    1201 mb,  4682 files,   C:\Windows\SysWOW64

    1190 mb,  5909 files,    C:\Windows\System32\DriverStore

    1186 mb,  5536 files,     C:\Windows\System32\DriverStore\FileRepository

    1085 mb,  2454 files,   C:\Windows\Microsoft.NET

  • Disk Drive C.jpg

    Please refer to screenshot:-



    Screenshot
    [edited by: Abhishek11 at 4:28 AM (GMT -7) on Sep 10, 2014]
  • I think I got it figured out.  The sfk.exe that originally came with the script is outdated.  Download the new one here stahlworks.com/.../sfk.exe

    You could also add a \ after the C: in the 4th line (that will get rid of the error).  But the new version has more, better info.

    The new one shows this at the top of the report:

    filesys="NTFS" volume="E44D5B73 OS" totalmb=499999 freemb=243428

    The old one would show this for the same command (after the trailing slash fix):

    NTFS E44D5B73 OS

    You don't have to change the script if you just update the sfk.exe file -- it works without the trailing slash fix

  • By the way, the second command in there sorts by largest directories.  It only shows directories that have more than 1GB in them. It only shows files if they are more than 1 GB.  (you can tweak that in the command)

    stahlworks.com/.../index.php

    stahlworks.com/.../index.php

  • C Drive.jpg

    Error part has been removed from the script but still i have tested it on 2 machines , script is not giving the actual result of space consumed or left or in short total space for C: drive . For example I am sending the screenshot and result that is taken from latest sfk.exe tool :

    filesys="NTFS" volume="F0254748 Windows7_OS" totalmb=103190 freemb=41688

    67175 mb, 150118 files, C:\

    67175 mb, 150118 files, 32025 dirs, 67175822811 bytes.

    33351 mb, 92563 files,  C:\Windows

    12889 mb,  5131 files,   C:\Windows\Installer

    11212 mb, 56672 files,   C:\Windows\winsxs

    5125 mb, 18652 files,  C:\Users

    5123 mb,  3837 files,  C:\SWTOOLS

    4272 mb, 16651 files,  C:\Program Files (x86)

    4131 mb,  4588 files,    C:\Windows\Installer\$PatchCache$

    4130 mb,  4572 files,     C:\Windows\Installer\$PatchCache$\Managed

    4011 mb,    15 files,  C:\System Volume Information

    3946 mb,                C:\pagefile.sys

    3589 mb, 10205 files,  C:\Program Files

    2960 mb,                C:\hiberfil.sys

    2786 mb,                 C:\System Volume Information\{5d68e1cd-3195-11e4-8a22-28d2440898ca}{3808876b-c176-4e48-b7ae-04046e6cc752}

    2518 mb,  2943 files,      C:\Windows\Installer\$PatchCache$\Managed\00005109110000000100000000F01FEC

    2514 mb,  8730 files,   C:\Users\aabhishek

    2491 mb, 12852 files,   C:\Windows\System32

    2095 mb,  8592 files,    C:\Users\aabhishek\AppData

    2062 mb,  7259 files,  C:\ProgramData

    2062 mb,  7259 files,   C:\Users\All Users

    1982 mb,  1923 files,   C:\Windows\assembly

    1791 mb,  7293 files,     C:\Users\aabhishek\AppData\Local

    1747 mb,  2484 files,   C:\SWTOOLS\DRIVERS

    1742 mb,  6335 files,   C:\Program Files\Microsoft Office

    1437 mb,   312 files,  C:\sounds

    1421 mb,  1212 files,       C:\Windows\Installer\$PatchCache$\Managed\00005109110000000100000000F01FEC\15.0.4420

    1268 mb,   586 files,   C:\SWTOOLS\readyapps

    1219 mb,  2963 files,    C:\Program Files\Microsoft Office\Office15

    1218 mb,  4788 files,   C:\Windows\SysWOW64

    1207 mb,                 C:\System Volume Information\{aca6c4a6-38af-11e4-b94a-28d2440898ca}{3808876b-c176-4e48-b7ae-04046e6cc752}

    1190 mb,  5909 files,    C:\Windows\System32\DriverStore

    1189 mb,   148 files,  C:\MSOCache

    1189 mb,   148 files,   C:\MSOCache\All Users

    1186 mb,  5536 files,     C:\Windows\System32\DriverStore\FileRepository

    1097 mb,  1730 files,       C:\Windows\Installer\$PatchCache$\Managed\00005109110000000100000000F01FEC\15.0.4569

    1085 mb,  2454 files,   C:\Windows\Microsoft.NET

  • If you right-click on your HDD and choose properties, you should see that the values match the bytes reported.  For example, the first line for me reports this:

    filesys="NTFS" volume="E44D5B73 OS" totalmb=499999 freemb=241064

    This is what I see for that drive's properties, which matches:

    Here is the reason for that: www.howtogeek.com/.../windows-hard-drive-wrong-capacity



    fixed something
    [edited by: kuuser at 8:35 AM (GMT -7) on Sep 12, 2014]
  • Oh, if you add -bin to the end of the first command it will report the binary MB.  Divide that by an additional 1024 and you should get the numbers to match



    edit: meant MB not GB
    [edited by: kuuser at 8:46 AM (GMT -7) on Sep 12, 2014]
  • So try changing the command to this:

    #agentTemp#\sfk.exe fsinfo C:\ -bin >> "#agentTemp#\DirUse-CDrive.txt"