Try/catch will handle the errors in case script can't access the folder. You need to recursively get all folders and subfolders, check inheritance for each and using Get-ACL and Set-ACL commadlets add permissions for the system account. You need to write a Powershell script for that. "Exception type is $($_.Exception.GetType().Name)" $AccessRule = New-Object ("System","FullControl, Synchronize", "ContainerInherit,ObjectInherit", "None", "Allow") $folders = (Get-ChildItem C:\Temp -Directory -Recurse) | select -ExpandProperty fullname Icacls.exe $item /grant 'System:(OI)(CI)(RX)'ĭidn`t found a solution with set-acl, maybe someone has an idea, this is my current set-acl state but the subfolder dont get the permissions even when they are inherited. $inheritance = (Get-Acl $item).access | select -ExpandProperty isinherited Thanks to Hardoman, here is a working solution for current folder, subfolder and files and without catching the error. And of course there are some Folders which are not accessible even by an Administrator account, so I need to ignore Errors.Īnyone aware of an script which can achieve this? I want to add a permission (System Account) to all explicit ACLs but not to those which are not explicit. subsubfolder 2 (explicit acl, no inherit acl) subsubfolder 1 (no explicit rights, inherit acl) subfolder 2 (explicit acl, no inherit acl) subfolder 1 (explicit acl, no inherit acl) We have a folder structure with many explicit rights like root Folder
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |