使用 Powershell 修改本地安全策略 [英] Modify Local Security Policy using Powershell

查看:58
本文介绍了使用 Powershell 修改本地安全策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Windows Server 2012.

I use Windows Server 2012.

我可以这样做:

在管理工具文件夹中,双击本地安全策略图标,展开帐户策略并单击密码策略.

In Administrative Tools folder, double click the Local Security Policy icon, expand Account Policies and click Password Policy.

在右侧窗格中双击密码必须满足复杂性要求并将其设置为禁用.单击确定"以保存您的政策更改.

In the right pane double click Password must meet complexity requirements and set it to Disabled. Click OK to save your policy change.

如何使用 Powershell 以编程方式执行此操作?

How can I do it programmatically using Powershell?

推荐答案

按照@Kayasax 的回答,没有纯粹的 powershell 方法,您必须将 secedit 包装到 Powershell 中.

There is no pure powershell way of doing it as per @Kayasax's answer, you have to wrap secedit into Powershell.

secedit /export /cfg c:\secpol.cfg
(gc C:\secpol.cfg).replace("PasswordComplexity = 1", "PasswordComplexity = 0") | Out-File C:\secpol.cfg
secedit /configure /db c:\windows\security\local.sdb /cfg c:\secpol.cfg /areas SECURITYPOLICY
rm -force c:\secpol.cfg -confirm:$false

这篇关于使用 Powershell 修改本地安全策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆