roboto404
(roboto404)
1
Hello,
I’ am a bit unfamiliar with creating scripts relating to registry changes. I usually manually edit registry changes for our production computers for it to auto-login to a certain account.
How would I create a script for the following changes?
Location:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
AutoAdminLogon value changed to ‘1’
Enter DefaultUsername ‘ProductionAccount’
Add String Value “DefaultPassword” and enter “Password”
Thank you.
2 Spice ups
Any reason why you choose bat vs powershell?
Using batch files (make sure you run elevated)
@echo off
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d ProductionAccount /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d Password /f
Powershell version (make sure you run elevated)
Set-Location -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Set-ItemProperty -Path . -Name "AutoAdminLogon" -Value "1" -Type String
Set-ItemProperty -Path . -Name "DefaultUserName" -Value "ProductionAccount" -Type String
Set-ItemProperty -Path . -Name "DefaultPassword" -Value "Password" -Type String -ErrorAction Stop
Edit: codestyle removed text cause it’s not necessary, included warning for elevated prompt
4 Spice ups
roboto404
(roboto404)
3
I’m new to scripting and our former sysadmin used batch files a lot so that is what I was mostly accustomed to. I’m open to using powershell and learning more about it.
Thank you so much for the help!
1 Spice up
Not a problem! Hope they help.
Powershell is really good for IT.
If you’re looking for good resources I’ve always recommended Microsoft Learn
3 Spice ups
I second that!
If you’re looking for a quick course on PowerShell, Learn PowerShell in a Month of Lunches
by Don Jones and Jeff Hicks is basically the gold standard, and is a great resource! (I just looked it up, and there’s apparently an Audiobook version now? I would highly suggest you get a print or digital copy, though. Listening to code, even with PowerShell’s syntax, sounds like a horrible time
There’s also a few new contributors on the newest versions, all 3 of the ones listed on the 4th edition seem to be pretty well respected folks in the PowerShell world, too!)
4 Spice ups