Solved

Retrieving quota size for single user problem.

Posted on 2006-06-11
6
780 Views
Last Modified: 2012-05-05
Hi, the following code will enumerate all users and retrieve their disk quota size, Do someone know how can I get disk quota size for just single user? Can I do something like that in sql statment: "Select * from Win32_DiskQuota where user='m' "? I did it but it does not work.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota")
For each objQuota in colQuotas
      Response.write "Volume: "& vbTab &  objQuota.QuotaVolume & "<br>"
      Response.write "User: "& vbTab &  objQuota.User& "<br>"
      Response.write "Limit: " & vbTab &  objQuota.Limit      & "<br>"  
      Response.write "Disk Space Used: "& vbTab &  objQuota.DiskSpaceUsed& "<br>"
      response.write "<p>"
Next
0
Comment
Question by:Abdu_Allah
  • 3
  • 3
6 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 500 total points
ID: 16880892
Try something like this

<%
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota where User='Win32_Account.Domain=""YOURDOMAIN"",Name=""Administrators""'")
For each objQuota in colQuotas
     Response.write "Volume: "& vbTab &  objQuota.QuotaVolume & "<br>"
     Response.write "User: "& vbTab &  objQuota.User& "<br>"
     Response.write "Limit: " & vbTab &  objQuota.Limit      & "<br>"  
     Response.write "Disk Space Used: "& vbTab &  objQuota.DiskSpaceUsed& "<br>"
     response.write "<p>"
Next
%>


hongjun
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16880956
It seems a good solution but why I got this error:
Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/login.asp, line 21, column 138
Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota where User='Win32_Account.Domain=""USER-89C9A"",Name=""m""'"))
0
 
LVL 33

Expert Comment

by:hongjun
ID: 16880968
You got an extra close bracket
Should be

Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota where User='Win32_Account.Domain=""USER-89C9A"",Name=""m""'")
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16880969
Ok this is my mistake I put a double brakets it works fine now. thanks.

0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16880979
By the way hongjun, this code needs administrative credential to be excuted what if the user(s) that loged in using Windows credential was not administrator! how can I execute this code? any idea?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 16880983
I believe this code is only for Administrators
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question