380 个问题
你好,
可以在脚本中使用secedit来配置本地安全策略。我写了一个PowerShell脚本供参考。这里将配置中的SeRemoteShutdownPrivilege设置为S-1-5-32-544即本地管理员组的SID。
$infpath = "C:\temp\sec.inf"
$dbpath = "C:\temp\sec.sdb"
$remoteshut = "SeRemoteShutdownPrivilege = *S-1-5-32-544"
secedit.exe /export /cfg $infpath /areas user_rights
$content = Get-Content -Path $infpath
for($i=0;$i -lt $content.Length;$i++) {
if($content[$i] -match "SeRemoteShutdownPrivilege") {
$content[$i] = $remoteshut
break
}
}
Set-Content -Path $infpath -Value $content
secedit.exe /configure /db $dbpath /cfg $infpath /areas user_rights
关于secedit的详细信息可以参考
https://learn.microsoft.com/zh-cn/windows-server/administration/windows-commands/secedit
祝好
Ian Xue
如果回答是有帮助的,请点击“接受答案”。