Add NTFS access to folder¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Import-Module -Name NTFSSecurity Enable-Privileges $BasePath = '' $AccessAccount = '' #Example: 'NT AUTHORITY\SYSTEM' $AccessRight = 'FullControl' Get-ChildItem $BasePath -Recurse -Directory | ForEach-Object { if ((Get-NTFSAccess -Path $($_.FullName) -Account $AccessAccount -ErrorAction SilentlyContinue).AccessRights -ne $AccessRight ) { Write-Host "Adding access to $($_.FullName)" -ForegroundColor Green Add-NTFSAccess -Path "$($_.FullName)" -Account $AccessAccount -AccessRights $AccessRight } } |