+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
Scripts Thread, Script to display remaining disk quota in Coding and Web Development; I have disk quotas set up on the homedrives of my users. These drivers are mapped to H: and take ...
  1. #1

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Script to display remaining disk quota

    I have disk quotas set up on the homedrives of my users. These drivers are mapped to H: and take the form of '\\svr1\y7 to y11\username', '\\svr2\y12 to y13\username' and '\\svr2\staff\username'.

    What I need to do is write a script to pop up a friendly message saying that a user is approaching their quota limit. This does not seem to be as easy as it sounds.

    If anybody has any ideas, please post!

  2. #2
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: Script to display remaining disk quota

    Umm didnt you write a script like this ages ago? If not you can get the values from WMI or have hardcoded ones. Where is the problem at?

  3. #3

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Re: Script to display remaining disk quota

    @ChrisH: I wrote a 'rough and ready' one that had hard coded values. What I want to do is use the disk quota functionality to determine the amount of space left.

    I'm having problems querying the WMI disk quota business though

  4. #4
    mrtechsystems's Avatar
    Join Date
    Jun 2005
    Location
    Yorkshire
    Posts
    424
    Thank Post
    96
    Thanked 22 Times in 22 Posts
    Rep Power
    25

    Re: Script to display remaining disk quota

    Could you please post the script would like this feature in my script would be a usefull thing

    Thanks

  5. #5

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,401
    Thank Post
    637
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    319

    Re: Script to display remaining disk quota

    Is this any good?

  6. #6

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Re: Script to display remaining disk quota

    Quote Originally Posted by mrtechsystems
    Could you please post the script would like this feature in my script would be a usefull thing

    Thanks
    I would if I could get it to work!

  7. #7
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: Script to display remaining disk quota

    Post what you have got then .

  8. #8

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to display remaining disk quota

    Doesn't vanilla Windows 200x server give warning anyway?

  9. #9
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: Script to display remaining disk quota

    Only in the log afaik.

  10. #10

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Re: Script to display remaining disk quota

    @NetworkGeezer: Don't think so... it tells you when you have reached your hard limit by saying that you have no space left though!

  11. #11

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Re: Script to display remaining disk quota

    OK... I think I'm getting somewhere now.

    I have discovered the following:
    * WMI scripting is slow
    * You cannot find the quota details out off the mapped user drive so you must point your script at the relevant server (hence I have to have my script decide which server to look at first)
    * To save luser confusion, you need to specify which volume on the server to look at (luckily for me, my pupil homedrives live on drive E: on both servers)

    The following is my pupil script (the staff one is slightly different because it looks at F: on svr2 only). It needs a little more testing but I think that it should work OK. If this messes anything up I am NOT responsible so test it yourself too!

    Code:
    ' Script to check how much disk quota a user has remaining
    ' and warn if approaching their limit.
    ' Author: Ric Charlton, 24/10/06
    
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    strDomainName= WshNetwork.UserDomain
    strUserName = WshNetwork.UserName
    
    If Left(strUserName, 1) = "0" then
    	strComputer = "svr1"
    Else
    	strComputer = "svr2"
    End If
    
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
    Set objQuota = objWMIService.Get _
        ("Win32_DiskQuota.QuotaVolume='Win32_LogicalDisk.DeviceID=""E:""'," & _
            "User='Win32_Account.Domain=""" & strDomainName & """,Name=""" & strUserName & """'")
    
    If objQuota.Status = 1 then
    	WScript.Echo "You are reaching your disk quota limit! " _
    		& "Consider deleting some of the files in your My Documents folder or see the Network Manager."
    	WScript.Echo "You only have " & (objQuota.Limit - objQuota.DiskSpaceUsed) / 1024 & "MB disk quota remaining!"
    Else
    	WScript.Echo "You have " & (objQuota.Limit - objQuota.DiskSpaceUsed) / 1024 & "MB disk quota remaining."
    End If
    BTW - Users without a disk quota set (i.e. no limit) get an odd looking amount of disk qota remaining message.

    Edit made!

  12. #12

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Re: Script to display remaining disk quota

    One slight problem is that 'regular' users cannot execute the GetObject command... hence the script doesn't work

    I will find a way around this though as it's something I really need to keep some of the staff user areas in check!

  13. #13
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: Script to display remaining disk quota

    I noticed with the new R2 features that you can make it email the user or the admin with these details.

  14. #14

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,235
    Thanked 1,044 Times in 966 Posts
    Rep Power
    363

    Re: Script to display remaining disk quota

    http://www.activexperts.com/activmon...DiskQuotas.htm

    Also not sure if this will help but instead of using GetObject() would it make any difference if you use

    WScript.GetObject()

    In your code

    Also if you have an if statement to check to see what values are returned for someone who has no limit and for someone who does have a limit on disk quoatas, that way you can check to see using an if statement if the user has a disk quota or not before you do the if statements to give the warning messages so you dont get that funky message at the end.

    Aside from that do the users have permissions in GPO to run or use scripting activex or scripts ? Just a thought as to why its being stopped.

    Hopefully this helps a bit

  15. #15

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115

    Re: Script to display remaining disk quota

    If anybody has any ideas, , please post!
    1) H: drive looks as big as their quota.
    2) WMI is relatively horrible.
    3) This is relatively easy:

    Code:
    var fso	= new ActiveXObject("Scripting.FileSystemObject");  
    
    if ( (fso.GetDrive("H:").FreeSpace/fso.GetDrive("H:").TotalSize) < 0.1 )
    
       WScript.Echo("You are approaching your disk quota limit! Blah-blah-blah..");
    You need to translate that from JScript.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 16th December 2007, 06:26 PM
  2. Disk quota problem
    By markman in forum Windows
    Replies: 4
    Last Post: 7th December 2007, 11:15 AM
  3. Disk Quota Reporting
    By NeoS in forum Windows
    Replies: 16
    Last Post: 9th July 2007, 06:47 PM
  4. Disk Quota Search
    By alonebfg in forum Windows
    Replies: 5
    Last Post: 1st November 2006, 08:24 PM
  5. Disk Quota
    By BKGarry in forum Scripts
    Replies: 3
    Last Post: 12th October 2006, 07:29 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •