公共/桌面 ACL 条目重置

公共/桌面 ACL 条目重置

我尝试减少 Windows 10 域成员对管理权限的需求。人们想要执行的一个常见操作是从共享公共桌面中删除桌面图标(因为软件安装程序很蠢)。因此,我添加了一个本地组,在其中添加了所有者用户(有点类似于高级用户),并在公共桌面文件夹中添加了带有“允许删除” ACL 条目的该组。这有效(在某种程度上,您必须打开文件夹并且无法直接在桌面上删除图标,但这是这个问题),但 ACL 似乎会定期重置(具有允许权限的此本地组的 ACE 已被删除)。

似乎有什么东西重置了文件夹权限,我不确定是什么。我们认为这不是组策略……至少不是故意的。Windows 中是否有一个权限模板可供该文件夹调整?(是什么触发了它的应用?)

这是脚本的一部分(可以运行,但是几天后设置就会丢失):

$PublicDesktop = "$env:Public\Desktop"
$localowneraccount = "$env:COMPUTERNAME\$localowners"
$acl = Get-Acl $PublicDesktop
$t = $null
$t = $acl.Access | where { $_.IdentityReference -eq $localowneraccount -and $_.FileSystemRights.ToString() -imatch "Delete"}
if ($t -eq $null) {
  $_perms = "$([System.Security.AccessControl.FileSystemRights]::Delete),$([System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles)"
  $_inherit = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit+[System.Security.AccessControl.InheritanceFlags]::ObjectInherit
  $_propagate = [System.Security.AccessControl.PropagationFlags]::InheritOnly
  $_allow = [System.Security.AccessControl.AccessControlType]::Allow
  $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($localowneraccount, $_perms, $_inherit, $_propagate, $_allow)
  $acl.AddAccessRule($AccessRule)
  $acl | Set-Acl $PublicDesktop -ErrorAction Stop
  Write-Host "Added Delete permission for Public Desktop to Group=<$localowners>"
} else {
  Write-Verbose "Public Desktop delete permission already granted to Group=<$localowners>"
}

相关内容