Enumerating Disk Quota Settings

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Keeping track of the quota settings on all volumes on a computer is an important administrative task. You need to know whether disk quotas have been enabled, and you need to know both the default quota and the actions the system takes if a user exceeds the quota. This information can be retrieved by using the DiskQuotaControl. Table 10.4 lists a subset of key properties for this object. All of these properties are read/write, meaning that scripts can be used to both configure and enumerate these settings.

Table 10.4   DiskQuotaControl Properties

PropertyDescription
DefaultQuotaLimitDefault limit (in bytes) set for quotas on this particular volume. If the DefaultQuotaLimit is -1, no quota limit has been set.
DefaultQuotaThresholdDefault warning limit (in bytes) set for quotas on this particular volume. If the DefaultQuotaThreshold is -1, no warning limit has been set.
LogQuotaLimitIndicates whether or not events are written to the event log if users exceed their quotas.
QuotaStateLevel of quota management set for this particular volume. Values are:

0 Quota management is not enabled on this volume.

1 Quotas are enabled on this volume, but are not enforced. Users are allowed to exceed their quota limit.

2 Quotas are tracked and enforced on this volume. Users are not allowed to exceed their quota limit.

LogQuotaThresholdIndicates that events are written to the event log when the warning limit is exceeded.

Scripting Steps

Listing 10.9 contains a script that enumerates the disk quota settings for drive C on a computer. To carry out this task, the script must perform the following steps:

  1. Create an instance of the DiskQuota1 object.
  2. Use the Initialize method to indicate that quota settings should be enumerated for drive C.

    The Initialize method requires the following two parameters:

    • The drive letter of the drive (in this case, C).
    • The value True, indicating that the drive should be initialized for read/write access. By setting this value to False, you can enumerate disk quota settings on the volume but you cannot make any changes (read-only).
  3. Echo the values of the disk quota settings.

    Because the quota state is returned as an integer (0 if quotas are disabled, 1 if quotas are enabled but not enforced, and 2 if quotas are enabled and enforced), an If Then construct is used to echo the appropriate message (for example, "Quota state: Disabled" if the value of the QuotaState property is 0).

Listing 10.9   Enumerating Disk Quota Settings

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 
Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1") colDiskQuotas.Initialize "C:\", True If colDiskQuotas.QuotaState = 2 Then     Wscript.Echo "Quota state: Enabled and enforced" ElseIf colDiskQuotas.QuotaState = 1 Then     Wscript.Echo "Quota state: Enabled but not enforced" Else     Wscript.Echo "Quota state: Disabled" End If Wscript.Echo "Default quota limit: " & colDiskQuotas.DefaultQuotaLimit Wscript.Echo "Default warning limit: " & _     colDiskQuotas.DefaultQuotaThreshold Wscript.Echo "Record quota violations in event log: " & _     colDiskQuotas.LogQuotaLimit Wscript.Echo "Record warnings in event log: " & _     colDiskQuotas.LogQuotaThreshold

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net