Friday, December 27, 2019

PowerShell: Configuring Windows Local Security Policy

Use the following PowerShell code to automate your Local Security Policy settings:

secedit /export /cfg $env:TEMP\tempsecpol.cfg
(GC $env:TEMP\tempsecpol.cfg) -Replace "PasswordComplexity = 1","PasswordComplexity = 0" `
| Out-File $env:TEMP\tempsecpol.cfg
secedit /configure /db $env:windir\security\local.sdb /cfg $env:TEMP\tempsecpol.cfg /areas SECURITYPOLICY
Remove-Item $env:TEMP\tempsecpol.cfg -Force

In this example, we disable the user password complexity requirement. Similarly, you can change other parameters in the uploaded policy configuration file. Also you must run the script with elevated privileges.

No comments:

Post a Comment