通过secedit工具设置本地安全策略

 1 #更改本地策略:设置密码永不过期、禁用密码复杂度
 2 $CurrentPath = $MyInvocation.MyCommand.Path.substring(0,$MyInvocation.MyCommand.Path.LastIndexOf('\')+1)
 3 If (Test-Path secedit.sdb) {Remove-Item secedit.sdb -Force}
 4 $secfile = join-path $CurrentPath "secpol.cfg"
 5 #导出当前安全策略模板
 6 secedit /export /cfg $secfile /quiet
 7 #禁用密码复杂度,设置密码永不过期
 8 ((gc $secfile) -replace "PasswordComplexity = 1", "PasswordComplexity = 0" ) -replace "MaximumPasswordAge = 42","MaximumPasswordAge = -1"| Out-File $secfile -force
 9 #导入新的安全策略模板(指定要应用到系统的安全性范围为SECURITYPOLICY)
10 secedit /configure /db secedit.sdb /cfg $secfile /areas SECURITYPOLICY /quiet
11 Remove-Item $secfile -Force
12 Remove-Item secedit.sdb -Force

 

相关文章:

  • 2021-12-09
  • 2021-08-24
  • 2022-12-23
  • 2022-01-12
  • 2021-04-17
  • 2021-12-09
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2021-11-14
  • 2022-12-23
  • 2021-12-14
相关资源
相似解决方案