I am writing a script that should set file system permissions for a folder and all content.
To affect all content, both subfolders and files, you must combine ContainerInherit and ObjectInherit according to the .NET documentation. But I can't get this to work, and I'm not sure about the syntax.
Code example:
$ar = new-object System.Security.AccessControl.FileSystemAccessRule(New-Object System.Security.Principal.NTAccount($user),FullControl,ContainerInherit,InheritOnly,Allow)
This will work and will only use ObjectInherit, but how can I combine them? Using quotes and commas like this "ContainerInherit,ObjectInherit"will not work, as it is not allowed to mix string and non-string arguments.
I also tried using the operator -and, but that just gives me an error. Assigning enumerations to a variable ( $inherit = ContainerInherit,ObjectInherit) will also not work.
So, any tips on how to do this?
source
share