Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ar = New-Object System.Security.AccessControl.FileSystemAccessRule("STATESVILLE\printer", "FullControl", "Allow")
  2.  
  3. $Homes = Get-ChildItem -Path "\\REDACTED\vol2\Homes\" -Depth 1
  4.  
  5. $Total = ($Homes | measure).count
  6. $Current = 0
  7. Foreach ($H in $Homes){
  8.     Write-progress -Activity "Setting Permissions..." -Status "Setting permissions on $($H.fullname)" -PercentComplete ($Current++/$total*100)
  9.     sleep 3
  10.     $acl = Get-Acl $H.FullName
  11.     $acl.SetAccessRule($ar)
  12.     Write-Host "Setting permissions on $($H.fullname)" -Fore yellow
  13.  
  14.     try {
  15.         $acl | Set-Acl $H.FullName -ErrorAction Stop
  16.         Write-host "Permissions set on $($H.fullname)" -Fore green
  17.     }
  18.     catch{
  19.         Write-host "Error encountered setting permissions: $_"
  20.     }  
  21. }
  22.  
  23. Write-host "Completed!" -fore cyan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement