Methods to wait until DC is fully booted in order to add another server as DC to that domain?

Viewed 162

I'm currently trying to create a PowerShell script which is capable of automatically creating Hyper-V VMs, configuring them and installing a AD domain.

Infrastructure: the script is creating 3 VMs: 2x Server 2016 Core (meant for the DCs) and 1x Windows 10 Pro

After creating a new forest with Install-ADDSForest. DC1 will automatically reboot. Directly after that DC2 is trying to execute Install-ADDSDomainController which is failing because it can't contact the domain, because something on DC1 isn't ready.

I've already tried to wait for PowerShell Direct & gpsvc (because the shell is showing "Waiting for gpsvc" for a long time.). I've also tried to ping the domain name and execute Install-ADDSDomainController after ICMP reply.

Now to my question: What service needs to be running in order to add the other server as a DC? I would then get the status of that service and continue my script if that named service is running.

I would also appreciate if someone could provide a different/better solution!

Thanks in advance.

Edit: I've found somewhat of a solution for my case: I'm now catching the error with try catch inside a do while loop.

0 Answers
Related