Wait for reboots in push mode

Hi,

I am using DSC in push mode to configure a set of (ESX) virtual machines. I have configured a DC using this method, and as you might expect this rebooted, and DSC waited for the reboot and then carried on (the relevant section of the log is below)

VERBOSE: [E1-DC]:                            [[VTAS_xADDomain]CreateDomain] ----------------------------------------
VERBOSE: [E1-DC]:                            [[VTAS_xADDomain]CreateDomain] Press CTRL-C to: Cancel
VERBOSE: [E1-DC]:                            [[VTAS_xADDomain]CreateDomain] Active Directory Domain Services is now installed on this computer for the domain "e1.local".

This Active Directory domain controller is assigned to the site "Default-First-Site-Name". You can manage sites with the Active Directory Sites and Services administrative tool.
VERBOSE: [E1-DC]: LCM:  [ End    Set      ]  [[VTAS_xADDomain]CreateDomain]  in 149.4850 seconds.
VERBOSE: [E1-DC]: LCM:  [ End    Resource ]  [[VTAS_xADDomain]CreateDomain]
VERBOSE: [E1-DC]:                            [] A reboot is scheduled to progress further. Configuration will be continued after the reboot.
WARNING: [E1-DC]:                            [] A reboot is scheduled to progress further. Configuration will be continued after the reboot.
VERBOSE: [E1-DC]: LCM:  [ End    Set      ]
VERBOSE: [E1-DC]: LCM:  [ End    Set      ]    in  331.2350 seconds.
WARNING: [WSManNetworkFailureDetected] The network connection to e1-dc has been interrupted. Attempting to reconnect for up to 4 minutes...
WARNING: [WSManConnectionRetryAttempt] Attempting to reconnect to e1-dc ...
WARNING: [WSManConnectionRetryAttempt] Attempting to reconnect to e1-dc ...
WARNING: [WSManConnectionRetryAttempt] Attempting to reconnect to e1-dc ...
WARNING: [WSManConnectionRetrySucceeded] The network connection to e1-dc has been restored.
VERBOSE: Operation 'Invoke CimMethod' complete.

However, when using xComputer from xComputerManagement (GitHub - dsccommunity/ComputerManagementDsc: DSC resources for for configuration of a Windows computer. These DSC resources allow you to perform computer management tasks, such as renaming the computer, joining a domain and scheduling tasks as well as configuring items such as virtual memory, event logs, time zones and power settings.) to join another computer to the domain, it seems that although DSC spots that a reboot is required, it won’t wait for that to happen, even if further items in the configuration are still yet to run. Instead, the configuration ends, and the machine does eventually reboot:

VERBOSE: [WIN-V1I2TNHNAJ3]: LCM:  [ Start  Test     ]  [[xComputer]JoinDomain]
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Importing the module MSFT_xComputer in force mode.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Importing the module MSFT_xComputer in force mode.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Validate desired Name is a valid name
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Checking if computer name is correct
VERBOSE: [WIN-V1I2TNHNAJ3]: LCM:  [ End    Test     ]  [[xComputer]JoinDomain]  in 1.6570 seconds.
VERBOSE: [WIN-V1I2TNHNAJ3]: LCM:  [ Start  Set      ]  [[xComputer]JoinDomain]
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Importing the module MSFT_xComputer in force mode.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Importing the module MSFT_xComputer in force mode.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Get-DSCConfiguration.cdxml'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Get-DSCLocalConfigurationManager.cdxml'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Restore-DSCConfiguration.cdxml'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Get-DscConfigurationStatus.cdxml'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Stop-DscConfiguration.cdxml'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Remove-DscConfigurationDocument.cdxml'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Disable-DscDebug.cdxml'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Enable-DscDebug.cdxml'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\DSCClassResources\WindowsPackageCab\WindowsPackageCab.psd1'.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\DSCClassResources\WindowsPackageCab\WindowsPackageCab.psm1'.
WARNING: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] The changes will take effect after you restart the computer WIN-V1I2TNHNAJ3.
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [[xComputer]JoinDomain] Renamed computer to 'e1-sql' and added to the domain 'e1.local.
VERBOSE: [WIN-V1I2TNHNAJ3]: LCM:  [ End    Set      ]  [[xComputer]JoinDomain]  in 23.7650 seconds.
VERBOSE: [WIN-V1I2TNHNAJ3]: LCM:  [ End    Resource ]  [[xComputer]JoinDomain]
VERBOSE: [WIN-V1I2TNHNAJ3]:                            [] A reboot is scheduled to progress further. Configuration will be continued after the reboot.
WARNING: [WIN-V1I2TNHNAJ3]:                            [] A reboot is scheduled to progress further. Configuration will be continued after the reboot.
VERBOSE: [WIN-V1I2TNHNAJ3]: LCM:  [ End    Set      ]
VERBOSE: [WIN-V1I2TNHNAJ3]: LCM:  [ End    Set      ]    in  43.0310 seconds.

What happens is that at some point the machine is rebooted, there is a pending configuration waiting to be completed. I assume that using

Start-DSCConfiguration -UseExisting
will finish the configuration off.

All the machines are configured the same way:

Configuration DscLcmConfiguration {
  Node $AllNodes.Where{$_.NodeName -notin "*","localhost"}.NodeName
  {
    Settings {
      DebugMode            = "ForceModuleImport"
      CertificateId        = $node.thumbprint
      ActionAfterReboot    = 'ContinueConfiguration'
      AllowModuleOverwrite = $true
      RebootNodeIfNeeded   = $true
   }
  }
}

What I’d like is for DSC to reboot the machine immediately and wait for the reboot to complete in the same way it did after domain creation. Is there any way I can achieve this?

Thanks

John

So, perusing the source for this module (https://github.com/PowerShell/xComputerManagement/blob/dev/DSCResources/MSFT_xComputer/MSFT_xComputer.psm1), we can see that it’s just using Add-Computer internally, which doesn’t itself trigger a reboot. It’s setting DSCMachineStatus = 1, which is what tells the LCM a reboot is needed. You’d need to do some diagnostic digging to see why it’s not obeying that right away, because in theory it should be working.

But you might also look at the xPendingReboot resource. Make it depend on the domain-join, and make everything else depend on it.

Thanks for your suggestion, Don

I agree that it seems like it should be working. My custom resource to configure the domain (the xADDomain resource does not offer an option to configure the domain without DNS, which is a requirement in our environment) sets $global:DSCMachineSTatus and that works just fine.

Would it be worth raising an issue against the PowerShell Github repo?

Thanks again

(Happy Thanksgiving to those in the US!)

Well, no, not until you’ve done some diagnostic spelunking to see if you can get any details about what’s happening. Like, enable a DSC trace, run the LCM, and then see what gets into the Debug and Analytic logs for DSC.