I am currently working on a school assignment where i have to make a couple of powershell scripts to perform a basic configuration of a windows server 2012 r2. First script needs to do the following:
o Server name: WDC
o Ip address: 192.168.1.45
o Subnet: 255.255.255.0
o Gateway: 192.168.1.1
o DNS: 192.168.1.1
o Administrator password: Admin2016
o Primaire DNS server 8.8.8.8
o Secundaire DNS server 192.168.1.45
o Promote to dc
o ...
Problem is that the server needs to reboot after the name change and that the script cannot continue after this.
I know I could do this by for example splitting up the script and continuing the second part with runonce in the registry after reboot, but my teacher swears that it is possible to do this in one ps1 file and furthermore he says that it should be possible to autologin after the reboot and then resume the same script file from where it stopped before the reboot.
This script has to be executed on a local machine, so I can't use workflows. I have been searching for a significant amount of time but can't seem to find any suitable solution to do this exactly how the teacher wants it.
Hope someone can help.
Cheers