Hello,
Another question about ACL and Inheritance.
I have a simple structure with E:\Test as the parent folder and "000", "001", "002", and "003" as subfolders. The subfolders inherit from E:\Test and the parent folder from the E: drive.
I need to break inheritance of the subfolders but keep the current ACL settings.
This is my first attempt:
$acl= Get-Acl E:\Test $acl.SetAccessRuleProtection($true,$true); Set-acl E:\Test\ $acl
This only changes the settings for the "Test" folder.
My next try was:
$dir = Get-Content E:\Folder.txt $acl = Get-Item $dir | Get-acl $acl.SetAccessRuleProtection($true,$true) $acl | Set-Acl
E:\Folders.txt contains the paths to the subfolders (i.e. E:\Test\000)
This pops some errors:
Get-Content : Cannot bind argument to parameter 'Path' because it is null.
At E:\New_Text_Document_2.ps1:2 char:28
+ $inheritance = Get-Content $dir | get-acl
+ ~~~~
+ CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetContentC
ommand
You cannot call a method on a null-valued expression.
At E:\New_Text_Document_2.ps1:3 char:1
+ $acl.SetAccessRuleProtection($true,$true)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Set-Acl : Cannot bind argument to parameter 'AclObject' because it is null.
At E:\New_Text_Document_2.ps1:4 char:27
+ $acl | Set-Acl -aclobject $inheritance
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-Acl], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetAclComma
nd
What I need is to be able to change the Inherit settings on all the subfolders of the parent folder. Every time I tried anything is always changes the parent folder but not the subfolders. I have been reading about this and I tried every script and solution presented but it seems that I`m doing something wrong because I can`t make it work.
Maybe someone can help me with this.
Thank you.