File Share Quota Management Tool is a powerful menu based PowerShell script used to remotely control the amount of disk/storage space that a user can utilize on the file server.

Quota manager tool will help system administrators to create, modify, enable or disable quotas on remote file servers.
The user-friendly navigation through the menus and the ability to remotely manage the quotas can saveĀ tremendous amount of time spent on manual quota processing during our daily admin tasks.
This tool is extremely helpful for managing file quotas on Windows servers with no PowerShell FSRM module support (which comes with Windows Server 2012).
Functions:
1. Adds New Quota
-Creates a new quota using standard user share template
2. Shows Quota & Local Drive Information
-Shows common quota parameters & local disk information
-Shows information (free space) for all available local disks (load balancing purposes)
3. Modifies Existing Quota
-Modifies the Quota Limit
-Applies New Standard Templates:
*User Predefined:
*4 GB User Share Hard Quota
*8 GB User Share Hard Quota
*12 GB User Share Hard Quota
*16 GB User Share Hard Quota
*20 GB User Share Hard Quota
*4 GB User Limit with 250 MB Extension
*8 GB User Limit with 250 MB Extension
*12 GB User Limit with 250 MB Extension
*16 GB User Limit with 250 MB Extension
*20 GB User Limit with 250 MB Extension
*Groups Predefined:
*10 GB Group Share Hard Quota
*20 GB Group Share Hard Quota
*30 GB Group Share Hard Quota
*40 GB Group Share Hard Quota
*50 GB Group Share Hard Quota
*10 GB Group Limit with 250 MB Extension
*20 GB Group Limit with 250 MB Extension
*30 GB Group Limit with 250 MB Extension
*40 GB Group Limit with 250 MB Extension
*50 GB Group Limit with 250 MB Extension
-Disables Quota
-Enables Quota
Requirements:
The script leverages the command-line FSRM utility dirquota and requires PSRemoting enabled on the target systems.
Tested on the following platforms:
Windows Server 2003
Windows Server 2008 R2
Download Link:
https://gallery.technet.microsoft.com/PowerShell-Tool-File-Share-560bde3b
The code:
In case your preferable way is to access the servers using their virtual names, you need to do few modifications:
-Uncomment line 51. The script will resolve server’s hostname form the DNS. To use FQDN type in the DNS suffix.
-Comment out line 49.
For retrieving the local disks information (lines 75,77) I used filtering to exclude all possible drives that I don’t want to monitor. Those are system drive, Quorum disk, drives that do not support any active shares. You may want to adjust this filtering to fitĀ with your environment configuration.
To change the standard quota templates use Find/Replace.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
<# .SYNOPSIS File Share Quota Manager v1.1 .DESCRIPTION Menu enabled quota manager. Leverages the FSRM dirquota command line tool. Requires PSRemoting enabled on target servers. Functions: 1. Adds New Quota -Creates a new quota using standard user share template 2. Shows Quota & Local Drive Information -Shows common quota parameters & local disk information -Shows information (free space) for all available local disks (load balancing purposes) 3. Modifies Existing Quota -Modifies the Quota Limit -Applies New Standard Templates: *User Predefined: *4 GB User Share Hard Quota *8 GB User Share Hard Quota *12 GB User Share Hard Quota *16 GB User Share Hard Quota *20 GB User Share Hard Quota *4 GB User Limit with 250 MB Extension *8 GB User Limit with 250 MB Extension *12 GB User Limit with 250 MB Extension *16 GB User Limit with 250 MB Extension *20 GB User Limit with 250 MB Extension *Groups Predefined: *10 GB Group Share Hard Quota *20 GB Group Share Hard Quota *30 GB Group Share Hard Quota *40 GB Group Share Hard Quota *50 GB Group Share Hard Quota *10 GB Group Limit with 250 MB Extension *20 GB Group Limit with 250 MB Extension *30 GB Group Limit with 250 MB Extension *40 GB Group Limit with 250 MB Extension *50 GB Group Limit with 250 MB Extension -Disables Quota -Enables Quota .NOTES File Name : quota-mgr.ps1 Author: Nikolay Petkov http://77.104.138.174/~powershe/power-shell.com #> $sharename = Read-Host "Share Name" $virtualname = Read-Host "Server Name" Write-host "Please Wait..." #HOSTNAME vs. VIRTUAL SERVER NAME $servername = $virtualname #Comment out if your input is a virtual server name. #Uncomment the following line if your input is a virtual server name. It will resolve the server's hostname and add the DNS suffix. #$servername = (get-wmiobject Win32_computersystem -computername $virtualname).DNSHostname + ".yourdomain.com" #MAIN MENU do { [int]$xMenuChoiceA = 0 while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 5 ){ Write-Host ā`t`tFile Share Quota Manager Version 1.1`nā -ForegroundColor Cyan Write-host "`t`t`t-MAIN MENU- $sharename" -Foregroundcolor GREEN Write-host "`t`t1. Show Quota & Local Drive Information" Write-host "`t`t2. Modify Existing Quota" Write-host "`t`t3. Add New Quota" Write-host "`t`t4. Get Help" Write-host "`t`t5. Quit" [Int]$xMenuChoiceA = read-host "`nPlease enter an option 1 to 5..." } #MAIN MENU - Show Quota & Local Drive Information Switch( $xMenuChoiceA ){ 1{ Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$virtualname ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q l /p:$localpath Write-Host "Local Disk Information for $sharename" Get-WmiObject -Class win32_logicaldisk -ComputerName $servername -Filter "DriveType=3" | where { $localpath -Like "$($_.Name)*" } | Select-Object -Property @{Name = 'DriveLetter'; Expression = {$_.DeviceID}}, VolumeName, @{n='Size';e={"{0:F2} GB" -f ($_.Size / 1gb)}}, @{n='FreeSpace';e={"{0:F2} GB" -f ($_.FreeSpace / 1gb)}} | Format-Table -AutoSize Write-Host "Possible New Location on $virtualname" Get-WmiObject -Class win32_logicaldisk -ComputerName $servername -Filter "DriveType=3" | where { $localpath -notLike "$($_.Name)*" -and $_.Name -notLike "C*" -and $_.Name -notLike "D*" -and $_.Name -notLike "Q*"} | Select-Object -Property @{Name = 'DriveLetter'; Expression = {$_.DeviceID}}, VolumeName, @{n='Size';e={"{0:F2} GB" -f ($_.Size / 1gb)}}, @{n='FreeSpace';e={"{0:F2} GB" -f ($_.FreeSpace / 1gb)}} | Format-Table -AutoSize } -argumentlist $servername,$sharename,$virtualname | out-host -paging } #-MENU MODIFY EXISTING QUOTA 2{[int]$xMenuChoiceA = 0 while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 5 ){ Write-host "`t`t`t-MODIFY EXISTING QUOTA- $sharename" -Foregroundcolor GREEN Write-host "`t`t1. Modify the Quota Limit" Write-host "`t`t2. Apply New Standard Template" Write-host "`t`t3. Disable Quota" Write-host "`t`t4. Enable Quota" Write-host "`t`t5. <-- Go to Main Menu" [Int]$xMenuChoiceA = read-host "`nPlease enter an option 1 to 5..."} #Modify the Quota Limit Switch( $xMenuChoiceA ){ 1{ Write-Host "`t`t`t-MODIFY THE QUOTA LIMIT- $sharename" -Foregroundcolor GREEN $NewLimit = Read-Host "Enter New Limit(GB)" Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path $ModifyLimit = dirquota q m /p:$localpath /limit:$NewLimit"GB" $ModifyLimit Write-Host "Quota Limit Modified Successfully to $NewLimit"GB"" -Foregroundcolor GREEN dirquota q l /p:$localpath } -argumentlist $servername,$sharename,$NewLimit } #--MODIFY EXISTING QUOTA MENU - APPLY NEW STANDARD TEMPLATE 2{[int]$xMenuChoiceA = 0 while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 3 ){ Write-host "`t`t`t-APPLY NEW AT&T STANDARD TEMPLATE- $sharename" -Foregroundcolor GREEN Write-host "`t`t1. User Standard Templates" Write-host "`t`t2. Group Share Standard Templates" Write-host "`t`t3. <-- Go to Main Menu" [Int]$xMenuChoiceA = read-host "`nPlease enter an option 1 to 3..." } #---MODIFY EXISTING QUOTA MENU - APPLY NEW AT&T STANDARD TEMPLATE - USER STANDARD TEMPLATES Switch( $xMenuChoiceA ){ 1{[int]$xMenuChoiceA = 0 while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 11 ){ Write-host "`t`t`t-USER STANDARD TEMPLATES- $sharename" -Foregroundcolor GREEN Write-host "`t`t1. 4 GB User Share Hard Quota" Write-host "`t`t2. 8 GB User Share Hard Quota" Write-host "`t`t3. 12 GB User Share Hard Quota" Write-host "`t`t4. 16 GB User Share Hard Quota" Write-host "`t`t5. 20 GB User Share Hard Quota" Write-host "`t`t6. 4 GB User Limit with 250 MB Extension" Write-host "`t`t7. 8 GB User Limit with 250 MB Extension" Write-host "`t`t8. 12 GB User Limit with 250 MB Extension" Write-host "`t`t9. 16 GB User Limit with 250 MB Extension" Write-host "`t`t10. 20 GB User Limit with 250 MB Extension" Write-host "`t`t11. <-- Go to Main Menu" [Int]$xMenuChoiceA = read-host "`nPlease enter an option 1 to 11..." } Switch( $xMenuChoiceA ){ 1{ Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"4 GB User Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename } 2{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"8 GB User Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 3{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"12 GB User Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 4{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"16 GB User Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 5{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"20 GB User Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 6{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"4 GB User Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 7{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"8 GB User Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 8{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"12 GB User Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 9{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"16 GB User Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 10{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"20 GB User Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} } } #---MODIFY EXISTING QUOTA MENU - APPLY NEW STANDARD TEMPLATE - GROUP SHARE STANDARD TEMPLATES 2{[int]$xMenuChoiceA = 0 while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 11 ){ Write-host "`t`t`t-GROUP SHARE STANDARD TEMPLATES- $sharename" -Foregroundcolor GREEN Write-host "`t`t1. 10 GB Group Share Hard Quota" Write-host "`t`t2. 20 GB Group Share Hard Quota" Write-host "`t`t3. 30 GB Group Share Hard Quota" Write-host "`t`t4. 40 GB Group Share Hard Quota" Write-host "`t`t5. 50 GB Group Share Hard Quota" Write-host "`t`t6. 10 GB Group Limit with 250 MB Extension" Write-host "`t`t7. 20 GB Group Limit with 250 MB Extension" Write-host "`t`t8. 30 GB Group Limit with 250 MB Extension" Write-host "`t`t9. 40 GB Group Limit with 250 MB Extension" Write-host "`t`t10. 50 GB Group Limit with 250 MB Extension" Write-host "`t`t11. <-- Go to Main Menu" [Int]$xMenuChoiceA = read-host "`nPlease enter an option 1 to 11..." } Switch( $xMenuChoiceA ){ 1{ Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"10 GB Group Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename } 2{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"20 GB Group Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 3{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"30 GB Group Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 4{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"40 GB Group Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 5{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"50 GB Group Share Hard Quota" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 6{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"10 GB Group Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 7{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"20 GB Group Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 8{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"30 GB Group Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 9{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"40 GB Group Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 10{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename,$NewLimit ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /sourcetemplate:"50 GB Group Limit with 250 MB Extension" dirquota q l /p:$localpath } -argumentlist $servername,$sharename} } } } } #--MODIFY EXISTING QUOTA MENU - Disable Quota 3{ Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /status:disabled dirquota q l /p:$localpath } -argumentlist $servername,$sharename} #--MODIFY EXISTING QUOTA MENU - Enable Quota 4. { Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q m /p:$localpath /status:enabled dirquota q l /p:$localpath } -argumentlist $servername,$sharename} } } #MAIN MENU - Add New Quota 3{[int]$xMenuChoiceA = 0 while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 3 ){ Write-host "`t`t`t-ADD NEW QUOTA- $sharename" -Foregroundcolor GREEN Write-host "`t`t1. Create New User Quota (4 GB User Share Hard Quota Template)" Write-host "`t`t2. Create New Group Share Quota (10 GB Group Share Hard Quota)" Write-host "`t`t3. <-- Go to Main Menu" [Int]$xMenuChoiceA = read-host "`nPlease enter an option 1 to 3..." } Switch( $xMenuChoiceA ){ 1{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q a /p:$localpath /sourcetemplate:"4 GB User Share Hard Quota" Write-Host "Quota created with the standard template: 4 GB User Share Hard Quota" -Foregroundcolor GREEN dirquota q l /p:$localpath } -argumentlist $servername,$sharename} 2{Invoke-Command -ComputerName $servername -ScriptBlock { param( $servername,$sharename ) $localpath = Get-WmiObject win32_share -ComputerName $servername | Where-Object {$_.name -match "$sharename"} | select -ExpandProperty path dirquota q a /p:$localpath /sourcetemplate:"10 GB Group Share Hard Quota" Write-Host "Quota created with the standard template: 10 GB Group Share Hard Quota" -Foregroundcolor GREEN dirquota q l /p:$localpath } -argumentlist $servername,$sharename} } } 4{ [System.Diagnostics.Process]::Start("http://power-shell.com/2014/powershell-scripts/file-share-quota-manager-tool-menu-based/") } } } while ( $xMenuChoiceA -ne 5 ) |


