At work, we use Quotas on our User’s Homedrives. There is a default Quota on the Shared Homedir folder. There used to be multiple of these folders, and when a user got a larger Quota, the homedir had to be moved + the user’s account hat to be altered accordingly. Since it is a mapped drive, which is also offline synced on the Notebooks, this lead to quite some administrative work, if the user got a larger Quota.
So I’ve decided to set the quota using Active Directory groups + Powershell. This runs daily in a scheduled task.
Limitation: I do not remove non default quotas, if a user should get a larger Quota for a limited period, the Quota is not automatically removed. Could be automated, but is not a valid scenario in our case.
# Der übergeordnete Userhome Ordner hat die default Quota # Die User welche in einer entsprechenden Quota-Gruppe sind erhalten die der Gruppe zugehörige Quota # Entfernen aus der Gruppe führt nicht zur Entfernung der Quota! # Nico Baumgartner, 27.07.2017 function set-homequota { param($group, $template) $ConfirmPreference = "none" $group = Get-ADGroupMember $group foreach ($user in $group) { $user = get-aduser $user -Properties homedirectory $homedir = "d:\home" + (get-item $user.HomeDirectory).BaseName if ($homedir -eq "d:\home") { $msg = "Fehler beim Setzen der Quota für " + $user.Name + ", Ungültiger Pfad." Write-EventLog -LogName "Application" -Source "Rhenus Quota Script" -EventId 200 -EntryType Error -Message $msg write-host $msg $homedir = "" #Vermeiden, dass Quota für den überliegenden D:\Home\ Ordner geschrieben wird. } $aktquota = Get-FsrmQuota $homedir if ($template -eq $aktquota.template) { Write-Host $template Write-Host $aktquota write-host "Richtiges Template bereits zugewiesen" für $user.Name } Else { Remove-FsrmQuota $homedir -Confirm:$false new-FSRMQuota $homedir -Template $template -Confirm:$false $aktquota = "" $aktquota = Get-FsrmQuota $homedir if ($template -eq $aktquota.template) { $msg = "Neue Quota gesetzt für " + $user.Name Write-EventLog -LogName "Application" -Source "Rhenus Quota Script" -EventId 101 -EntryType Information -Message $msg Write-Host $msg } Else { $msg = "Fehler beim Setzen der Quota für " + $user.Name Write-EventLog -LogName "Application" -Source "Rhenus Quota Script" -EventId 200 -EntryType Error -Message $msg write-host $msg } } } } # New-EventLog -Source "Rhenus Quota Script" -LogName "Application" Write-EventLog -LogName "Application" -Source "Rhenus Quota Script" -EventId 100 -EntryType Information -Message "Rhenus Quota Script gestartet" $qgroup = "AA_RAG_CH_HomedriveQuota_0500MB_LG" $template = "Rhenus 0500MB Homedrive" set-homequota $qgroup $template $qgroup = "AA_RAG_CH_HomedriveQuota_2000MB_LG" $template = "Rhenus 2000MB Homedrive" set-homequota $qgroup $template $qgroup = "AA_RAG_CH_HomedriveQuota_8000MB_LG" $template = "Rhenus 8000MB Homedrive" set-homequota $qgroup $template