Reputation: 884
I am trying to create a script that will pass down inheritance of the subfolder.
For example:
C:/template has x y z permissions
C:/template/test only has x permissions
I want all sub folders and files from C:/template to get the x y z permissions.
Something similar to the script here that Robert Prust made (it does not execute):
$ACL = Get-Acl -Path C:\Template
$Folders = Get-ChildItem -Recurse -Path "C:\new_perm" -Filter 'Subfolder*' | Select-Object -ExpandProperty FullName
foreach ($Folder in $Folders) {
# write the variables found - check if the folder path is correct
# Write-Output "This foldername is $Folder"
# convert foldername to a icacls approved path
$icacls = "$Folder\*"
# check if the icacls path is correct
# Write-Output "icacls path is $icacls"
#set the ACL required on the folder
Set-ACL -Path $Folder -AclObject $ACL
# replace all child permissions for the folder
icacls $icacls /q /c /t /reset
}
Thanks,
Jonathan
Upvotes: 0
Views: 1542
Reputation: 200503
Just run icacls "C:\template\*" /q /c /t /reset
. It doesn't get simpler than that.
Upvotes: 4