
我嘗試減少 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>"
}