raandree / NTFSSecurity

Managing permissions with PowerShell is only a bit easier than in VBS or the command line as there are no cmdlets for most day-to-day tasks like getting a permission report or adding permission to an item. PowerShell only offers Get-Acl and Set-Acl but everything in between getting and setting the ACL is missing. This module closes the gap.
MIT License
431 stars 61 forks source link

How to apply multiple permissionchanges at once #28

Closed Xento closed 6 years ago

Xento commented 6 years ago

Is it possible to apply multiple permissionchanges at once? For example remove one group and add an other in one run? Actually it first performs the remove and then it adds the group because this are two independent cmdlet calls.

raandree commented 6 years ago

You, can achieve this by using the following sequence:


$sd = Get-NTFSSecurityDescriptor -Path D:\AL1.json

$sd | Disable-NTFSAccessInheritance -RemoveInheritedAccessRules
$sd | Add-NTFSAccess -Account Everyone -AccessRights Read -AppliesTo ThisFolderSubfoldersAndFiles
$sd | Add-NTFSAccess -Account Administrators -AccessRights FullControl -AppliesTo ThisFolderSubfoldersAndFiles

$sd | Set-NTFSSecurityDescriptor