Set quotas depending on whether staff, student, or both
From MyWiki
# Read the list of home folders from FS03 $lines = get-content dirlstFS03.txt $lines | foreach-object{ $homefolderpath = $_ $homefoldername = $_ -Split('\\') Write-Host $homefoldername[2] # Filter the account name and print $username = $homefoldername[2] try { if ( get-aduser $username ) ## In this section a valid user has been identified { Write-Host "user $username exists" $account = get-aduser $username -properties * $office = $account.Office Write-host " The office is $office" $a = get-adprincipalgroupmembership $username | select name if ( ( $a -Match "staff-gg-all_staff" ) -And ( $a -Match "student-gg-all_students" ) ) { Write-Host "Member of: staff and student" Write-Host "Setting staff/student quota for user $username" new-fsrmquota $homefolderpath -Template "750 MB Staff & Student Report to User" } ElseIF ( $a -Match "staff-gg-all_staff" ) { write-host "Member of:staff" Write-Host "Setting staff quota for user $username" new-fsrmquota $homefolderpath -Template "500 MB Staff Report to User" } ElseIF ( $a -Match "student-gg-all_students" ) { write-host "Member of: student" Write-Host "Setting student quota for user $username" new-fsrmquota $homefolderpath -Template "250 MB Students Report to User" } Else { Write-Host "Unidentified, therefore setting quota from Office attribute " if ( $office -eq "Student" ) { Write-Host "Setting student quota for user $username" new-fsrmquota $homefolderpath -Template "250 MB Students Report to User" } ElseIF ( $office -eq "Staff" ) { Write-Host "Setting staff quota for user $username" new-fsrmquota $homefolderpath -Template "500 MB Staff Report to User" } Else { new-fsrmquota $homefolderpath -Template "250 MB Extended Limit" } } } } catch { Write-Host "Account $username is not valid in this system" new-fsrmquota $homefolderpath -Template "250 MB Extended Limit" } }