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
to list the members of a local group and
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
: -logonname -setlimit -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
`) do diskquotas.pl -create : -logonname %i -setlimit -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.