|
|
@@ -0,0 +1,36 @@
|
|
|
+param(
|
|
|
+ $Username = $null,
|
|
|
+ $Pass = $null
|
|
|
+)
|
|
|
+
|
|
|
+### The code below configures Auto-Login on Windows computers ###
|
|
|
+
|
|
|
+<#
|
|
|
+
|
|
|
+Author: Patrick Gruenauer | Microsoft MVP on PowerShell
|
|
|
+Web: https://sid-500.com
|
|
|
+
|
|
|
+#>
|
|
|
+
|
|
|
+hostname
|
|
|
+if ($null -eq $Username){
|
|
|
+ $Username = Read-Host 'Enter username for auto-logon (f.e. contoso\user1)'
|
|
|
+}
|
|
|
+
|
|
|
+if ($null -eq $Pass){
|
|
|
+ $Pass = Read-Host "Enter password for $Username"
|
|
|
+}
|
|
|
+$RegistryPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
|
|
|
+Set-ItemProperty $RegistryPath 'AutoAdminLogon' -Value "1" -Type String
|
|
|
+Set-ItemProperty $RegistryPath 'DefaultUsername' -Value "$Username" -type String
|
|
|
+Set-ItemProperty $RegistryPath 'DefaultPassword' -Value "$Pass" -type String
|
|
|
+
|
|
|
+Write-Warning "Auto-Login for $username configured. Please restart computer."
|
|
|
+
|
|
|
+$restart = Read-Host 'Do you want to restart your computer now for testing auto-logon? (Y/N)'
|
|
|
+
|
|
|
+If ($restart -eq 'Y') {
|
|
|
+
|
|
|
+ Restart-Computer -Force
|
|
|
+
|
|
|
+}
|