Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Replace child object permissions on existing folders/subfolders/files

$
0
0

Update:

I think I have found the solution.
While not completely using PowerShell, it seems to be the quickest solution.

Tipped by Vern’s post above and searching, I found this article which does what I required.
Combined with my previous scripts, I’ve come to the following solution:

$ACL = Get-Acl -Path C:\Customer\Projects\permissions\Template
$Folders = Get-ChildItem -Recurse -Path "D:\Data\Projects" -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
}

I’ve tested this on several test folders and they all obtain the permissions I’ve set on my Template folder.
Thanks for the push in the right direction, I hope this also helps others!

Kind regards
Robert


Viewing all articles
Browse latest Browse all 13067

Trending Articles