Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
111
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. Foreach ($H in $Homes){
  5.     $acl = Get-Acl $H.FullName
  6.     $acl.SetAccessRule($ar)
  7.     Write-Host "Setting permissions on $($H.fullname)" -Fore yellow
  8.  
  9.     try {
  10.         $acl | Set-Acl $_.FullName -ErrorAction Stop
  11.         Write-host "Permissions set on $($H.fullname)" -Fore green
  12.     }
  13.     catch{
  14.         Write-host "Error encountered setting permissions: $_"
  15.     }  
  16. }
  17.  
  18. Write-host "Completed!" -fore cyan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement