|
|
@@ -1,6 +1,8 @@
|
|
|
param(
|
|
|
$Username = $null,
|
|
|
- $Pass = $null
|
|
|
+ $Pass = $null,
|
|
|
+ [Parameter(HelpMessage="Disables AutoLogin")]
|
|
|
+ [switch]$Disable = $false
|
|
|
)
|
|
|
|
|
|
### The code below configures Auto-Login on Windows computers ###
|
|
|
@@ -12,7 +14,16 @@ Web: https://sid-500.com
|
|
|
|
|
|
#>
|
|
|
|
|
|
+$RegistryPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
|
|
|
+
|
|
|
hostname
|
|
|
+
|
|
|
+if ($Disable) {
|
|
|
+ Set-ItemProperty $RegistryPath 'AutoAdminLogon' -Value "0" -Type String
|
|
|
+ Get-ItemProperty $RegistryPath 'AutoAdminLogon'
|
|
|
+ exit
|
|
|
+}
|
|
|
+
|
|
|
if ($null -eq $Username){
|
|
|
$Username = Read-Host 'Enter username for auto-logon (f.e. contoso\user1)'
|
|
|
}
|
|
|
@@ -24,7 +35,6 @@ if ("" -eq $Username) {
|
|
|
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
|