# Set Variables
$Username = Read-Host -Prompt "Enter the username for automatic login"
$Password = Read-Host -Prompt "Enter the password for automatic login" -AsSecureString
$PlainPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
    [Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)
)
$Domain = "."  # Use '.' for local machine or specify domain if applicable

# Registry Path for auto-login
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"

# Set registry values for auto-login
Set-ItemProperty -Path $RegPath -Name "AutoAdminLogon" -Value "1"
Set-ItemProperty -Path $RegPath -Name "DefaultUsername" -Value $Username
Set-ItemProperty -Path $RegPath -Name "DefaultPassword" -Value $PlainPassword
Set-ItemProperty -Path $RegPath -Name "DefaultDomainName" -Value $Domain

Write-Host "Automatic login has been configured. Restart the computer to test."
