Folder Size Inventory Using ConfigMgr

Folder Size Inventory Using ConfigMgr

One more script to help inventory the size of a specified set of folders (or just a single folder if that’s all you are interested in) using ConfigMgr. Similar to my other inventory scripts, this is a VBScript that needs to be run on the target systems. This can be done using a package and program or compliance settings. Also similar to my other inventory scripts, the data is stored in a custom WMI namespace, named ITLocal, and a custom WMI class, named Folder_Size. You can easily change these on lines 3 and/or 4 of the script. From there, add the WMI class to your ConfigMgr hardware inventory (as outlined in my post Collecting USMT Estimates using ConfigMgr post). To change which folders the script collects information on, simply edit line 7.

And that’s it.

Folder Size Inventory



  1. Hello, Jason. Thanks for the post.
    Can you write this *.mof file (which need to be added to default client settings in ConfigMgr hardware inventory) or link to download it?
    Another question: in what views in database I can see the results?

    • No .mof needed, just use the GUI.

      It will create new views prefixed with v_GS and v_HS named for the exact class name you use. In the case if you directly use my scripts, it’ll be v_GSFolderSize and v_HSFolder_Size (or something real close to that as I’m not in front of my lab at the moment).

  2. HI Jason, Thanks for the post.
    This script is running on clients then how its creating views on server DB.
    something else need to be done on server site in client default settings?

    • Yes. It’s the same as all hardware inventory. You need to add the WMI class to your hardware inventory in your applicable client settings package(s).

  3. HI JAson

    I am trying to inventory the C:users folder on the machines. I have edited line 7, added the extension as per your other guide, but i seem to be getting a ‘Null’ Size on my Size0 section

    • Hi Leon, Can you post exactly what you changed line 7 to?

      Have you run the script manually with line 35 uncommented?

  4. Thanks for the post Jason

  5. Hi Jason,

    Like Leon, i want to use your script on c:users folder. Doesn’t work. This is the output :

    – c:users :

    Line 7 : FOLDERS = array (“c:users”)
    Line 35 is uncommented.


  6. Jason, this looks very promising.
    I open an administrative command prompt and ran the folder-size.vbs, but cannot tell if it worked….
    On line 7, I changed my folders to be what I wanted for testing, and then ran the script.
    I am searching through wbem test to see if I can see the classes and nothing shows.
    I opened my admin console on the server and the default policy, and after connecting to my machine I cannot see any of the new hardware inventory classes.
    Am I just completely missing something?

    • Hi Greg,

      You have to also add the created WMI class to hardware inventory in client settings. The script simply stores the values in WMI, you have to tell ConfigMgr to collect that info using hardware inventory.

      Also note that you need to run the script as a local admin otherwise the script can;t create the namespace and class.

      Assuming you left the default namespace and class name, you can run the following in PowerShell to check the results of the script within in WMI: Get-WMIObject -namespace rootITLocal -Class Folder_size

  7. I have run the script, but it doesn’t appear to be creating the WMI Namespace (using your Get-WMIobject command above). I am on Windows 10 1703. Any help would be appreciated. My bosses are requesting this info.

    • Did you run the script elevated? Creating a WMI namespace and class requires local admin permissions.

      • I did, and it still did not work.

        • The Get-WMIObject command above is wrong — it’s missing a slash. It should be Get-WMIObject -namespace root\ITLocal -Class Folder_size assuming that you haven’t changed the namespace or class name.

  8. HI JAson

    I am trying to inventory the C:users folder on the machines. I have edited line 7, added the extension as per your other guide, but i seem to be getting a ‘Null’ Size on my Size0 section

    FOLDERS = array (“C:\Users”,”%Temp%”)
    Running in an admin command prompt on win 10, I get the following:

    – C:\Users :
    – %Temp% : 1518.278

    • Long overdue answer here. I honestly don’t know exactly why, but the Size method of the Folder object within the Scripting.FileSystemObject COM object throws an access denied on C:\Users even if run from a command-prompt run as the local System. That’s quite odd and not sure if this is a Win 10 thing or if it was always like that. This must be a bug in this COM object IMO but don’t honestly know. It might be because of this Junction Dysfunction ( but I honestly don’t know.

  9. Thanks, Jason.

    Trying to get this to work and the Namespace and Class are created, but the Size isn’t there. I am trying to recurse C:\Users, but even if I drill down to a user folder C:\Users\ it doesn’t show me size…

    If I uncomment line 36 to get the echo, that also doesn’t return a size.

    Everything being run w/ elevated permissions.

    Win 10 1607

    __GENUS : 2
    __CLASS : Folder_Size
    __DYNASTY : Folder_Size
    __RELPATH : Folder_Size.Path=”C:\\Users”
    __DERIVATION : {}
    __PATH : \\REDACTED\ROOT\ITLocal:Folder_Size.Path=”C:\\Users”
    Path : C:\Users
    Size :
    PSComputerName : REDACTED

    • Sorry, long overdue reply here. As the script was written, it’s not supposed to recurse into any subfolders. That could easily be added, but it’s just not what it does today.

  10. Hi, script works correctly, but the size for some folders is empty. why? The permissions on the folders are the same for all the server at the test. thanks!

    • Don’t know. Have you tried to run the code manually to see the output?

      • yes, for me is because the path of the folder is too long, more 255 characters.. you know a solution to bypass? thanks

    • I have kinda the same issue, I’m looking at sizes for Userprofile\Pictures, Desktop, Favorites, Music and Documents. All report the correct sizes, except for Documents. That size always returns NULL. Folder perms seem to be setup properly. Returns Null running via SCCM or Manually. Puzzled.

      • The FileSystemObject used by VBScript and this script doesn’t deal with access denied permissions well and likes to just give up when it hits anything that it doesn’t have permissions to — I suspect that’s what you are running into. This causes pain with this script for sure. Re-writing the script in PowerShell is definitely in order.

  11. Hi,
    The script works fine for me. WMI Namespace got created and folder size fetching in WMI successfully.

    Now. When I am adding WMI in hardware inventory in SCCM, I am only able to connect for one. what computer name should I use while adding class.
    Please help!

    • Any computer that has the class. When you adding info to hardware inventory, it’s not computer specific, it’s just pulling the class and attribute info from that computer.

      • Hi Jason,
        I have defined 7 path in array and it is returning only first path out of 7. I have mentioned path like – %userprofile%\Desktop, %Userprofile%\Document and so on. Any suggestion!

        • Hi Anil,

          Can you please post the exact line in the script that you modified to add the folders? Also, it’s been a while so I can’t say for sure whether the script will expand environment variables or not. Have you tried, as a test, hard-coding a path?