使用 PowerShell 将文件夹权限应用于文件夹内容
Apply folder permissions to folder contents with PowerShell
我正在为特定用户的文件夹应用 "Read" 权限。我希望他们能够阅读里面的记事本文件。
$Acl = Get-Acl "C:\Test"
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("MyUser","Read","Allow")
$Acl.SetAccessRule($Ar)
Set-Acl "C:\Test" $Acl
我的代码正确地将读取权限应用到文件夹(我可以手动检查 "Security tab to see this), but does not grant access to the files inside. Access is denied when "MyUser" 尝试打开记事本文件。
您需要使用另一个 constructor 以便为容器和叶对象设置 InheritanceFlags。尝试:
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("MyUser","Read","ContainerInherit,ObjectInherit", "None", "Allow")
我正在为特定用户的文件夹应用 "Read" 权限。我希望他们能够阅读里面的记事本文件。
$Acl = Get-Acl "C:\Test"
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("MyUser","Read","Allow")
$Acl.SetAccessRule($Ar)
Set-Acl "C:\Test" $Acl
我的代码正确地将读取权限应用到文件夹(我可以手动检查 "Security tab to see this), but does not grant access to the files inside. Access is denied when "MyUser" 尝试打开记事本文件。
您需要使用另一个 constructor 以便为容器和叶对象设置 InheritanceFlags。尝试:
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("MyUser","Read","ContainerInherit,ObjectInherit", "None", "Allow")