Skip to content

Instantly share code, notes, and snippets.

@boranbar
Last active July 17, 2025 12:34
Show Gist options
  • Select an option

  • Save boranbar/d3f9eb649d9d490ba94997d6baec7773 to your computer and use it in GitHub Desktop.

Select an option

Save boranbar/d3f9eb649d9d490ba94997d6baec7773 to your computer and use it in GitHub Desktop.
PowerShell Script to Modify Password Policy and Create Local Administrator Users
# Parola politikalarını düzenle
secedit /export /cfg "$env:TEMP\secpol.cfg"
(gc "$env:TEMP\secpol.cfg") |
ForEach-Object {
$_ -replace 'PasswordComplexity\s*=\s*\d+', 'PasswordComplexity = 0' `
-replace 'MinimumPasswordLength\s*=\s*\d+', 'MinimumPasswordLength = 0'
} | Set-Content "$env:TEMP\secpol.cfg"
secedit /configure /db secedit.sdb /cfg "$env:TEMP\secpol.cfg" /areas SECURITYPOLICY
# Grup ilkesi güncelle
gpupdate /force
Start-Sleep -Seconds 3
# Kullanıcı listesi (kullanıcı adı ve şifre) – Administrator hariç
$users = @{
"ALI" = "123456"
"VELI" = "123456.."
"HASAN" = "123456xxx"
"HUSEYIN" = "123456asdasd"
}
# Kullanıcıları oluştur ve yöneticilere ekle
foreach ($user in $users.Keys) {
$username = $user
$password = $users[$user] | ConvertTo-SecureString -AsPlainText -Force
# Kullanıcıyı oluştur (eğer yoksa)
if (-Not (Get-LocalUser -Name $username -ErrorAction SilentlyContinue)) {
New-LocalUser -Name $username -Password $password -FullName $username
Write-Host "Kullanıcı oluşturuldu: $username"
} else {
Write-Host "Kullanıcı zaten mevcut: $username"
}
# Yöneticilere ekle
Add-LocalGroupMember -Group "Administrators" -Member $username -ErrorAction SilentlyContinue
Write-Host "Yönetici grubuna eklendi: $username"
}
@boranbar
Copy link
Author

boranbar commented Jul 13, 2025

🛠️ How to Use

  1. Create the script file
    Save the PowerShell script as create_users.ps1 on your Desktop.

  2. Run the script
    Open PowerShell as Administrator and execute the following commands:

    cd ~\Desktop
    powershell -ExecutionPolicy Bypass -File .\create_users.ps1
    
    

✔️ This will:

  • Disable password complexity requirements
  • Set the minimum password length to 0 characters
  • Create the listed users (if they don’t already exist)
  • Add them to the Administrators group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment