根据this article,使用PowerShell或cmd,我要强制用户具有特定的密码要求。我尝试在secedit
中编辑配置文件。
secedit /export /cfg c:\secpol.cfg
$min_pass_regex = "MinimumPasswordLength = \d+"
$min_pass_length = 10
$min_pass_requirement = "MinimumPasswordLength = $($min_pass_length)"
(gc C:\secpol.cfg).replace("RequireLogonToChangePassword = 0", "RequireLogonToChangePassword = 1") | Out-File C:\secpol.cfg
(gc C:\secpol.cfg).replace("PasswordComplexity = 0", "PasswordComplexity = 1") | Out-File C:\secpol.cfg
(gc C:\secpol.cfg) -replace $min_pass_regex, $min_pass_requirement | Out-File C:\secpol.cfg
cat C:\secpol.cfg
secedit /configure /db c:\windows\security\local.sdb /cfg c:\secpol.cfg /areas SECURITYPOLICY
但是,即使重新启动,用户也不会收到警告以创建更安全的密码。如何执行此政策?