github.com/cloudfoundry-incubator/stembuild@v0.0.0-20211223202937-5b61d62226c6/modules/BOSH.Autologon/BOSH.Autologon.psm1 (about)

     1  <#
     2  .Synopsis
     3      Configure Autologon
     4  .Description
     5      This cmdlet enables/disables the Autologon
     6  #>
     7  
     8  $RegistryKey="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
     9  
    10  function Enable-Autologon {
    11      Param (
    12          [Parameter(Mandatory=$true)][string]$Password,
    13          [string]$User="Provisioner"
    14      )
    15  
    16      Write-Log "Enable Autologon"
    17      Set-ItemProperty -Path $RegistryKey -Name AutoAdminLogon -Value 1 -Force
    18      Set-ItemProperty -Path $RegistryKey -Name AutoLogonCount -Value 50 -Force
    19      Set-ItemProperty -Path $RegistryKey -Name DefaultUserName -Value $User -Force
    20      Set-ItemProperty -Path $RegistryKey -Name DefaultPassword -Value $Password -Force
    21  }
    22  
    23  function Disable-Autologon {
    24      Write-Log "Disable Autologon"
    25      Set-ItemProperty $RegistryKey -name AutoAdminLogon -value 0
    26  }