PS: grant user access to folders
$usersid = New-Object System.Security.Principal.Ntaccount("ADDOMAIN\ad_user")
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($usersid,[System.Security.AccessControl.FileSystemRights]::ReadAndExecute, [System.Security.AccessControl.AccessControlType]::Allow)
Get-ChildItem -Recurse -Directory . | % {
Write-Host "Setting rights to $($_.FullName)"
$fld = $_.FullName
$acl = get-acl $fld
$acl.PurgeAccessRules($usersid)
$acl.SetAccessRule($accessRule)
$acl | Set-Acl $fld
}
Comments