Script repository

Remove disk quota for user on the drive where the user's home directory is located

Updated on: Jan 18, 2026, Views: 3712

Approval requests

The script removes disk quota for the user on the drive where the user’s home directory is located. To execute the script, create a business rule, scheduled task or custom command configured for the User object type.

$homeDirectoryPath = "%homeDirectory%"
$homeDirectoryPath = $homeDirectoryPath.Replace("\\", "")
$homeDirectoryPathParts = $homeDirectoryPath.Split("\")

# Get disk quota object for the computer where the user's home folder is located
$objQuotas = Get-WMIObject Win32_DiskQuota -ComputerName $homeDirectoryPathParts[0]

$domainName = $Context.GetObjectDomain("%distinguishedName%")
$flatDomainName = $domainName.SubString(0,$domainName.IndexOf("."))

foreach($objQuota in $objQuotas)
{
    # Find disk quotas for the target user
    if($objQuota.User -eq 'Win32_Account.Domain="' + $flatDomainName + '",Name="' + "%username%" + '"')
    {
        $Context.LogMessage("Disk quota deleted for user %username% on the following volume: " + $objQuota.QuotaVolume, "Information")
        $objQuota.Delete()
        return
    }
}

$Context.LogMessage("No disk quota found for user %username% on server " + $homeDirectoryPathParts[0], "Information")

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.