Enumerates disk quota information (including user name, warning and quota limits, and disk space used) for each disk quota entry on a computer.

JavaScript
Edit|Remove
var wbemFlagReturnImmediately = 0x10;
var wbemFlagForwardOnly = 0x20;

   var objWMIService = GetObject("winmgmts:\\\\.\\root\\CIMV2");
   var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskQuota", "WQL",
                                          wbemFlagReturnImmediately | wbemFlagForwardOnly);

   var enumItems = new Enumerator(colItems);
   for (; !enumItems.atEnd(); enumItems.moveNext()) {
      var objItem = enumItems.item();

      WScript.Echo("Disk Space Used: " + objItem.DiskSpaceUsed);
      WScript.Echo("Limit: " + objItem.Limit);
      WScript.Echo("Quota Volume: " + objItem.QuotaVolume);
      WScript.Echo("Status: " + objItem.Status);
      WScript.Echo("User: " + objItem.User);
      WScript.Echo("Warning Limit: " + objItem.WarningLimit);
      WScript.Echo();
   }