Execute PowerShell Script Automatically after Server Reboot

This PowerShell Script is very useful for my lab testing, and here is what it do

  1. Set the Time Zone, Rename the Computer Name, Configure the IP Address, Disable Windows Firewall and Enable Remote Desktop
  2. Restart by itself – Add a value to “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\run”
  3. Once User login to the computer, it will automatically join to the AD Domain defined – I’m still exploring how to fully automate the script even without users login

Explanation of the Script

  1. Function.ps1 – Define all the functions here
  2. Startup.ps1 – Perform the tasks to Set Time Zone, Rename the Computer and etc and inset the joindomain.ps1 to “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\run” at the end of the script to execute it once the server is rebooted with user login
  3. joindomain.ps1 – join the server to AD Domain and remove the Registry Key inserted in Step 2

Step to execute the script

  1. Copy the following script to a folder, like c:\temp\startup
  2. .\startup.ps1

I’m still studying and exploring some improvement on this area, and will update again on this soon.

Share This