MDT - Autologon nach Installation aktiviert lassen
In letzter Zeit beschäftige ich mich wieder intensiv mit dem MDT, um unsere Schulungs-Rechner mit neuen Windows 10 Images zu versehen. Dafür habe ich ein kleine Powershell-Funktion geschrieben, den den Autologon für einen Benutzer setzt (s.u.). Sie kann den Autologon aktivieren. Leider funktioniert die Funktion nicht innerhalb eines Konfigurationsskriptes im MDT, da nach erfolgter Installation das Aufräumskript Scripts\LTICleanup.wsf den Autologon entfernt. Um den Autologon beizubehalten oder ändern zu können, suchen Sie den Text
'//---------------------------------------------------------------------------- '// Clear the autologon registry keys '//----------------------------------------------------------------------------
und kommentieren Sie die nachfolgenden Zeilen bis zum nächsten Kommentarblock mit dem ' aus.
function Set-AutomaticLogon{<#.Synopsis Enables Windows Autologon or removes it.DESCRIPTION This function enables Windows Autologon via Registry-Keys or disables it. It is similar to the Netplwiz.exe Command.EXAMPLE Set-AutomaticLogon -Enabled -Username Student -Password Password Adds an Autologon-Key to the Registry..EXAMPLE Set-AutomaticLogon -Disabled Disables the automatic Logon by removing the User-Password and disabling the Logon-key. #>param( [parameter(Mandatory=$True, ParameterSetName='Enabled')] [switch]$Enabled,
[parameter(Mandatory=$True, ParameterSetName='Disabled')] [Switch]$Disabled,
[parameter(Mandatory=$True, ParameterSetName='Enabled')] [string]$Username, [parameter(Mandatory=$True, ParameterSetName='Enabled')] [string]$Password,
[parameter(ParameterSetName='Enabled')] [string]$DomainName = ( Hostname ))
$winLogonKey = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
If ( $PSCmdlet.ParameterSetName -eq 'Enabled') { Set-Itemproperty -path $winLogonKey -Name 'AutoAdminlogon' -Value 1 Set-Itemproperty -path $winLogonKey -name 'DefaultUserName' -Value $Username Set-Itemproperty -path $winLogonKey -name 'DefaultPassword' -Value $Password Set-Itemproperty -path $winLogonKey -name 'DefaultDomainName' -Value $DomainName Remove-ItemProperty -Path $winLogonKey -Name 'AutoLogonCount' -Force } Else { Set-Itemproperty -path $winLogonKey -name 'AutoAdminlogon' -Value 0 Remove-ItemProperty -Path $winLogonKey -name 'DefaultPassword' -ErrorAction SilentlyContinue Remove-ItemProperty -Path $winLogonKey -name 'DefaultUserName' -ErrorAction SilentlyContinue Set-Itemproperty -path $winLogonKey -name 'DefaultDomainName' -ErrorAction SilentlyContinue Remove-ItemProperty -Path $winLogonKey -Name 'AutoLogonCount' -Force }}
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.
Comments