Solved

Retrieving quota size for single user problem.

Posted on 2006-06-11
6
763 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

18 Experts available now in Live!

Get 1:1 Help Now