将所有受限应用程序包添加到文件夹权限

Guy*_*ann 1 windows security permissions file-permissions windows-10

我无法将用户 ALL RESTRICTED APPLICATION PACKAGES 添加到在 Windows 10 中创建的文件夹的权限列表中。如何使用 Windows 资源管理器(安全——> 高级)完成此操作?

Ian*_*emp 5

似乎不可能ALL RESTRICTED APPLICATION PACKAGES通过 Windows 资源管理器添加,但这可以通过一个小 PowerShell 轻松实现:

$user = [Security.Principal.NTAccount]::new("ALL RESTRICTED APPLICATION PACKAGES").Translate([System.Security.Principal.SecurityIdentifier])
$rule = [Security.AccessControl.FileSystemAccessRule]::new($user, "ReadAndExecute", "Allow") # or whatever permissions you require, you can change them later via Explorer
$directory = "path/to/your/directory"
$acl = Get-Acl $directory
$acl.SetAccessRule($rule)
Set-Acl -Path $directory -AclObject $acl
Run Code Online (Sandbox Code Playgroud)

但是,对于您的情况 - 想要将权限从一个目录批量复制到另一个目录 - 您最好复制权限,而不是尝试手动添加它们。对于该任务,您可以使用Copy-AclPowerShell 脚本:

Copy-ACL -SourcePath "C:\Windows\System32\spool" -DestinationPath "my_new_spool_directory_location" -BreakInheritance -KeepInherited
Run Code Online (Sandbox Code Playgroud)