|
|
@@ -1,7 +1,7 @@
|
|
|
param(
|
|
|
$Username = $null,
|
|
|
$Pass = $null,
|
|
|
- [Parameter(HelpMessage="Disables AutoLogin")]
|
|
|
+ [Parameter(HelpMessage = "Disables AutoLogin")]
|
|
|
[switch]$Disable = $false
|
|
|
)
|
|
|
|
|
|
@@ -24,7 +24,7 @@ if ($Disable) {
|
|
|
exit
|
|
|
}
|
|
|
|
|
|
-if ($null -eq $Username){
|
|
|
+if ($null -eq $Username) {
|
|
|
$Username = Read-Host 'Enter username for auto-logon (f.e. contoso\user1)'
|
|
|
}
|
|
|
|
|
|
@@ -32,19 +32,17 @@ if ("" -eq $Username) {
|
|
|
throw "Username is Empty!"
|
|
|
}
|
|
|
|
|
|
-if ($null -eq $Pass){
|
|
|
+if ($null -eq $Pass) {
|
|
|
$Pass = Read-Host "Enter password for $Username"
|
|
|
}
|
|
|
-Set-ItemProperty $RegistryPath 'AutoAdminLogon' -Value "1" -Type String
|
|
|
-Set-ItemProperty $RegistryPath 'DefaultUsername' -Value "$Username" -type String
|
|
|
+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
|
|
|
-
|
|
|
}
|