Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ar = New-Object System.Security.AccessControl.FileSystemAccessRule("STATESVILLE\printer", "FullControl", "Allow")
- $Homes = Get-ChildItem -Path "\\REDACTED\vol2\Homes\" -Depth 1
- $Total = ($Homes | measure).count
- $Current = 0
- Foreach ($H in $Homes){
- Write-progress -Activity "Setting Permissions..." -Status "Setting permissions on $($H.fullname)" -PercentComplete ($Current++/$total*100)
- sleep 3
- $acl = Get-Acl $H.FullName
- $acl.SetAccessRule($ar)
- Write-Host "Setting permissions on $($H.fullname)" -Fore yellow
- try {
- $acl | Set-Acl $H.FullName -ErrorAction Stop
- Write-host "Permissions set on $($H.fullname)" -Fore green
- }
- catch{
- Write-host "Error encountered setting permissions: $_"
- }
- }
- Write-host "Completed!" -fore cyan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement