Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Retrieving quota size for single user problem.

Posted on 2006-06-11
6
Medium Priority
?
814 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

648 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