Skip to content

Instantly share code, notes, and snippets.

@themaximax
Last active December 24, 2024 13:42
Show Gist options
  • Save themaximax/74936c6e608d29d086402e4670c86278 to your computer and use it in GitHub Desktop.
Save themaximax/74936c6e608d29d086402e4670c86278 to your computer and use it in GitHub Desktop.
Скрипт для отключения полики сложности и длины паролей. Может пригодиться, когда комп уже введёт в домен, а нужно создать/изменить ограниченную локальную учётку
# !скрипт запускать от имени администратора
# куда сохранять
$file = Join-Path -Path $env:TEMP -ChildPath 'sec.inf'
# экспортируем параметры безопасности в файл
SecEdit.exe /export /cfg $file
# читаем файл в переменную
$content = Get-Content $file
# меняем значения ключей, с помощью регулярного выражения
$content = $content -replace '^(PasswordComplexity|MinimumPasswordLength).*', '$1 = 0'
# пишем обратно в файл
Set-Content -Path $file -Value $content
# импортируем измененные политики
SecEdit.exe /configure /db $env:windir\security\edit.sdb /cfg $file /areas SECURITYPOLICY
# удаляем за собой
Remove-Item -Force $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment