Script repository
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.