Copying lists and entries

Access lists can be copied from one object to another; for example, a template ACL might have been prepared:

$acl = Get-Acl C:TempACL4 
$acl.SetAccessRuleProtection($true, $true)
$acl.Access |
Where-Object IdentityReference -like '*Authenticated Users' |
ForEach-Object { $acl.RemoveAccessRule($_) }
Set-Acl C:TempACL4 –AclObject $acl

This ACL can be applied to another object:

$acl = Get-Acl C:TempACL4 
Set-Acl C:TempACL5 -AclObject $acl 

If ACL contains a mixture of inherited and explicit entries, the inherited entries will be discarded.

Access control rules may be copied in a similar manner:

# Get the ACE to copy 
$ace = (Get-Acl C:TempACL3).Access | Where-Object {
    $_.IdentityReference -like '*Authenticated Users' -and 
    $_.FileSystemRights -eq 'Modify, Synchronize' -and 
     -not $_.IsInherited 
}

# Get the target ACL $acl = Get-Acl C:TempACL5

# Add the entry $acl.AddAccessRule($ace)

# Apply the change Set-Acl C:TempACL5 -AclObject $acl
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.102.178