Subscribe to Windows IT Pro
May 30, 2001 12:00 AM

Apply Disk Quotas to Groups

Windows IT Pro
InstantDoc ID #20981
Rating: (3)
Type just one line to set a disk quota for everyone in a group

Windows 2000's disk quotas don't let you assign different disk quotas to different groups of users—you can't give 100MB quotas to everyone in the Engineers group and 20MB quotas to everyone in the Managers group. But two Microsoft Windows 2000 Server Resource Kit tools give you a rudimentary solution that will let you type one line to set a disk quota for everyone in a group.

Showmbrs.exe lists the members of a specified group. You type

showmbrs <groupname>

to list the members of a local group and

showmbrs \\<domainname>\<groupname>

to list a domain's groups or a remote machine's local groups.

Diskquotas.pl is a Perl script that lets you create, modify, delete, copy, list, import, and export quota information about disk volumes. Options let you create a quota entry of a given size for a given user on a given volume. The syntax is

diskquotas.pl -create <drive>: -logonname 
<username> -setlimit <size> -silent

where drive is a drive letter, username is a username with or without a domain prefix, and size is an integer to which you append KB, MB, GB, TB, PB, or EB (to indicate kilobyte, megabyte, gigabyte, terabyte, petabyte, or exabyte, respectively). The -silent option tells diskquotas.pl to skip any prompts and just do what you tell it to do. If Bob is a member of the Acme domain and I want to set his disk quota to 500MB on the local server's D drive, I would type

diskquotas.pl -create d: 
-logonname acme\bob 
-setlimit 500MB

If Bob already has a quota entry, diskquotas.pl would ask me whether it should replace Bob's old quota value with the new value.

Clearly, diskquotas.pl is useful, but it's only a user-by-user tool. To set a quota for everyone in a group, you need to use Win2K's and Windows NT's powerful For command to capture the names of the group members with Showmbrs, then you need to feed that list of members to diskquotas.pl:

for /f "usebackq skip=2" %i in 
(`showmbrs <groupname>`)
do diskquotas.pl -create <drive>:
-logonname %i -setlimit <size> -silent

Be sure to type the command as one line and substitute appropriate values for groupname, drive, and size.

Simplified, here's how For works. The command

for /f "usebackq skip=2" %i in (`firstcommand`)
do secondcommand %i

executes the command named Firstcommand and feeds its output to a command called Secondcommand. The /f portion of the command string tells the For command to parse (i.e., return the first token on) each line of output Firstcommand produces as input to Secondcommand. Notice that I embed the first command within backward single quotes. The usebackq option tells the For command to treat the string within backward quotes as an executable command. The skip=2 parameter tells For to ignore the first two lines of Firstcommand's output—the first two lines of Showmbr's output are header lines.

The first %i in the command string specifies the variable For uses to store Firstcommand's output. You can give the variable any name prefixed by a percent sign. The second %i tells Secondcommand to use Firstcommand's output values. To run this command from a batch file, you must substitute %%i for both occurrences of %i in the command string.

All in all, this process is an ugly way to assign disk quotas to a group. But I hope you'll find it a useful one.

Related Content:

ARTICLE TOOLS

Comments
  • Anne
    4 years ago
    Mar 25, 2008

    Hi José, thanks for your question. I'll do a little research to see if I can find an answer for you. Thanks for reading!
    Anne Grubb, Web site editor, Windows IT Pro

  • joseestrela
    4 years ago
    Mar 11, 2008

    Hello

    I'm a new one.

    Does anyone knows a way of set quotas to all members of one group at same time?

    I tried look at this "http://www.admin-pains.com/group_quota.asp" but had no luck.

    José Cruz
    Portugal

  • Frane
    5 years ago
    Mar 13, 2007

    I like this solution:

    http://www.admin-pains.com/group_quota.asp

  • Giles Pallister
    8 years ago
    May 18, 2004

    Still can't find DISKQUOTAS.PL. It's either well-hidden, or W2KS RK Supp1 isn't supplied on Technet (how do I tell which version of Reskit I have?)

  • Dan
    9 years ago
    Sep 10, 2003

    diskquotas.pl is on the win2k server resource kit supplement 1

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.