Deleting a Disk Quota Entry

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

The DiskQuotaControl object includes a DeleteUser method that you can use to delete quota entries from a quota table. This method is useful for keeping your quota tables up to date. For example, if a user leaves the organization, you can remove his or her quota entry to ensure that the quota table reflects only valid users and user accounts.

It is important to note that deleting a quota entry does not deny the user the right to store files on the volume. If you delete a user s quota entry and the user attempts to store something on the volume, a brand-new quota entry is created for the user. You need to use NTFS permissions to deny a user permission to store files on a volume.

In addition, you cannot delete quota entries from the disk quota table as long as the user still owns any files or folders on the volume. If a user leaves the organization, you must perform one of the following actions before you can delete a user s quota entry:

  • Move all the files or folders owned by the user to another volume.
  • Take ownership of all the files or folders owned by the user.

Scripting Steps

Listing 10.15 contains a script that deletes the disk quota entry for a user. 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 the quota entry to be deleted is on drive C.

    The Initialize method requires the following two parameters:

    • The drive letter of the drive where the quota resides (in this case, C).
    • The value True, indicating that the drive should be initialized for read/write access. Setting this value to False allows you to enumerate disk quota entries on the volume but does not allow you to change the disk quota entries.
  3. Use the FindUser method to query the quota entry for a user, (in this case, jsmith from the fabrikam domain).
  4. Use the DeleteUser method to delete the quota entry for jsmith from the fabrikam domain.

Listing 10.15   Deleting a Disk Quota Entry

1 2 3 4 
Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1") colDiskQuotas.Initialize "C:\", True Set objUser = colDiskQuotas.FindUser("fabrikam\jsmith") colDiskQuotas.DeleteUser(objUser)

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