首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >通过命令查询密码复杂度是否开启,并设置关闭/开启密码复杂度

通过命令查询密码复杂度是否开启,并设置关闭/开启密码复杂度

原创
作者头像
Windows技术交流
修改于 2022-11-05 18:06:10
修改于 2022-11-05 18:06:10
8.9K0
举报
文章被收录于专栏:Windows技术交流Windows技术交流

云上不要禁用密码复杂度,禁用了会有坑,什么坑就不说了,肯定是安全的坑。

server系统本来默认就是开启密码复杂度,但PC系统默认是关闭的,这就被我发现坑了,如果你在云上使用win7、win10等,一定要开启密码复杂度。

如何查询密码复杂度是否开启?以管理员身份打开cmd命令行执行如下命令

secedit /export /cfg c:\secpol.cfg

echo. >c:\out.txt

type c:\secpol.cfg | findstr -i complex >>c:\out.txt

type c:\out.txt

如果结果为PasswordComplexity = 1,代表密码复杂度已开启

如果结果为PasswordComplexity = 0,代表密码复杂度未开启

如果想要禁用密码复杂度,以管理员身份打开cmd命令行执行如下命令

secedit /export /cfg c:\secpol.cfg

echo. >c:\out.txt

type c:\secpol.cfg | findstr -i complex >>c:\out.txt

powershell -command "(GC C:\secpol.cfg) -Replace \"PasswordComplexity = 1\",\"PasswordComplexity = 0\" | Out-File C:\secpol.cfg"

echo. >>c:\out.txt

type c:\secpol.cfg | findstr -i complex >>c:\out.txt

secedit /configure /db c:\windows\security\local.sdb /cfg c:\secpol.cfg /areas SECURITYPOLICY

del /q c:\secpol.cfg

type c:\out.txt

del /q c:\out.txt

del %windir%\security\logs\scesrv.log

如果要开启密码复杂度,以管理员身份打开cmd命令行执行如下命令

secedit /export /cfg c:\secpol.cfg

echo. >c:\out.txt

type c:\secpol.cfg | findstr -i complex >>c:\out.txt

powershell -command "(GC C:\secpol.cfg) -Replace \"PasswordComplexity = 0\",\"PasswordComplexity = 1\" | Out-File C:\secpol.cfg"

echo. >>c:\out.txt

type c:\secpol.cfg | findstr -i complex >>c:\out.txt

secedit /configure /db c:\windows\security\local.sdb /cfg c:\secpol.cfg /areas SECURITYPOLICY

del /q c:\secpol.cfg

type c:\out.txt

del /q c:\out.txt

del %windir%\security\logs\scesrv.log

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档