# This script assumes a neat CSV of usernames has been provided. Save this CSV into C:\Scripts cd \ cd scripts $inputFile = Import-CSV C:\scripts\PHPUsers.csv foreach($line in $inputFile) { $username = $line.username # e.g. jsmith12 (samid) dsquery user "OU=Students,OU=Users,OU=School,dc=domain,dc=local" -samid $username | dsmod group "CN=PHP Server User,OU=Groups,OU=School,dc=domain,dc=local" -addmbr $user = "domain\" + $username #e.g. domain\jsmith12 (needed for permissions) #switch case is based on last two digits in username switch -wildcard ($username) { "*06" { $path = "\\server\wwwroot\2006\" + $username ./SetFolderPermission.ps1 -Path $path -Access $user -Permission FullControl } "*07" { $path = "\\server\wwwroot\2007\" + $username ./SetFolderPermission.ps1 -Path $path -Access $user -Permission FullControl } "*08" { $path = "\\server\wwwroot\2008\" + $username ./SetFolderPermission.ps1 -Path $path -Access $user -Permission FullControl } "*09" { $path = "\\server\wwwroot\2009\" + $username ./SetFolderPermission.ps1 -Path $path -Access $user -Permission FullControl } "*10" { $path = "\\server\wwwroot\2010\" + $username ./SetFolderPermission.ps1 -Path $path -Access $user -Permission FullControl } "*11" { $path = "\\server\wwwroot\2011\" + $username ./SetFolderPermission.ps1 -Path $path -Access $user -Permission FullControl } "*12" { $path = "\\server\wwwroot\2012\" + $username ./SetFolderPermission.ps1 -Path $path -Access $user -Permission FullControl } } Write-Host "`n" } # pause script so we can see error messages Write-Host "Completed! Press any key to close." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")