Solved

Retrieving quota size for single user problem.

Posted on 2006-06-11
6
773 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IIS POST request being ignored 4 53
toggle checkboxes when a checkbox is checked 16 51
Update field in order 21 119
Server Timeout with Loop 6 36
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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now