How to force DSC to execute all configurations (Packages) even when a restart/reboot is required

Solution 1:

I came up with this solution

I'd like to find a better way to do it though. But anyways it works for me

I still believe that the DSC process should notify me somehow, not just via Write-Verbose because in my case this process is kicked off as part of our Continuous Integration Process

[int]$maximumAttempts = 5
[int]$attempt = 0
[ValidateNotNull()][guid]$dscResTmp = [guid]::NewGuid()
[ValidateNotNullOrEmpty()][string]$dscResPathTmp = Join-Path $baseFolderPathTmp "$dscResTmp.log"

do
{
    [bool]$stopLoop = $false
    [int]$attempt = ++$attempt

    Start-DscConfiguration -Wait -Force -Path $folderPathTmp 4> $dscResPathTmp

    [string[]]$rebootServerCoincidences = Select-String -Pattern "reboot" -Path $dscResPathTmp

    if ($rebootServerCoincidences.Length -le 0)
    {
        [bool]$stopLoop = $true
    }
    else
    {
        Write-Warning ($rebootServerCoincidences -join [Environment]::NewLine)
    }
}
while($stopLoop -eq $false -and $attempt -le $maximumAttempts)

if ($stopLoop -eq $false)
{
    Write-Warning "Max attempts reached"
}