0
我想使用PowerShell刪除註冊表項的用戶權限,但有困難。當前登錄的用戶(User.Test)可以完全控制密鑰Internet Settings
,但是當作爲計劃任務運行下面的腳本時,它無法成功移除用戶。有人可以幫忙嗎?通過PowerShell的權限註冊表
Set-ExecutionPolicy UnRestricted
$acl = Get-Acl -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings"
$acl | Format-List
$user = New-Object System.Security.Principal.NTAccount("Domain\User.Test")
$permission = [System.Security.AccessControl.RegistryRights]"FullControl"
$inherit = [System.Security.AccessControl.InheritanceFlags]::None
$propagation = [System.Security.AccessControl.PropagationFlags]::None
$type = [System.Security.AccessControl.AccessControlType]::Allow
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($user, $permission, $inherit, $propagation, $type)
$acl.RemoveAccessRuleAll($rule)
$acl | Set-Acl