Automating Windows domain login through Powershell.

If you are a Windows administrator, you know the registry is key to automation and troubleshooting client machines. Of course automating logins is very useful with lots of machines that do the same thing. We have a group of machines at one plant’s sole purpose is data collection. The shop users are not interested in remembering password, so automating the login is a must.
Here is a list of the keys required that can be entered through Powershell remotely through a PSSession, which I enabled through a Windows login startup script using enable-psremoting -force.
Here are the (4) keys required to auto login a domain user, you need to create 3 new entries and modify just 1:

remove-itemProperty 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultDomain
remove-itemProperty 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUserName
remove-itemProperty 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword
remove-itemProperty 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon
new-ItemProperty 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultDomainName -type string -Value domainname
new-ItemProperty 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUsername -type string -Value username
new-ItemProperty 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -type string -Value password
new-ItemProperty 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon -type string -Value 1