The 2003 powershell goes on :-)
Again, there are no available modules so i had to create my own.
How to set disk quota for a certain user (in megabytes) on a certain Windows 2003 server on a certain drive? Here’s how:
function set_disk_quota($username, $quota_hard, $computername, $disk) { # preferred quota mode is enabled+deny access to disk, which is type 2 # for logging purposes only but still allow disk access, select type 1 $default_quota_mode = "2" $query_quota_enabled_or_not = "select * from Win32_QuotaSetting where VolumePath='"+$disk+":\\'" $query_user = "select * from Win32_Account where name='"+$username+"'" $query_disk = "select * from Win32_LogicalDisk where DeviceID='"+$disk+":'" $quota_disk = get-wmiobject -query $query_quota_enabled_or_not -computername $computername if ($quota_disk.State -eq "0") { echo "CHECK - ERROR - state 0 = Quota not enabled on disk -$disk- of -$computername-" echo "setting quota" $quota_disk.State = $default_quota_mode $quota_disk.Put() } if ($quota_disk.State -eq "1") { echo "CHECK - WARNING - state 1 = Quota enabled on disk -$disk- of -$computername- but not access is not denied when over quota" echo "setting quota" $quota_disk.State = $default_quota_mode $quota_disk.Put() } if ($quota_disk.State -eq "2") { echo "CHECK - OK - state 2 = Quota enabled on disk -$disk- of -$computername- and access is denied when over quota" } $objAccount = get-wmiobject -query $query_user $objDisk = get-wmiobject -query $query_disk $objquota = (new-object management.managementclass Win32_DiskQuota).CreateInstance() $objquota.User = $objAccount.Path.RelativePath $objquota.QuotaVolume = $objDisk.Path.RelativePath if ($quota_hard -eq "0") { $objquota.Delete() echo "Quota deleted for $username" } else { $objquota.Limit = [int]$quota_hard * 1024 * 1024 * 1 # Set the warning level to 90% of the $hard_limit $objquota.WarningLimit = [int]$quota_hard * 1024 * 1024 * 0.9 $objquota.put() } }