设置本地安全策略

通过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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值