6

From MSDN

RebootNodeIfNeeded: Certain configuration changes on a target node might require it to be restarted for the changes to be applied. With the value “true,” this property will restart the node immediately and without warning. If “false,” the configuration will be completed, but the node must be restarted manually for the changes to take effect.

So my understanding is that DSC should run all the configurations even if a restart is required

But in my case that's not true, after installing a Package sometimes the DSC is marked to reboot and DSC doesn't run the rest of the configurations

I have to manually execute the command again to be run the rest of the configurations

Start-DscConfiguration -Wait -Force -Path .\SomePath

I would like to force DSC to run all configurations and then inform me if I need to restart the server

Examples of how I'm configuring Packages

    LocalConfigurationManager
    {
        RebootNodeIfNeeded = $false
    }

   Package MVC3
    {
        Name = "Microsoft ASP.NET MVC 3"
        Ensure = "Present"
        Path = "$Env:SystemDrive\AspNetMVC3ToolsUpdateSetup.exe"
        ProductId = "DCDEC776-BADD-48B9-8F9A-DFF513C3D7FA"
        Arguments = "/q"
        DependsOn = "[WindowsFeature]IIS"
        Credential = $Credential
    }

   Package MVC4
    {
        Name = "Microsoft ASP.NET MVC 4 Runtime"
        Ensure = "Present"
        Path = "$Env:SystemDrive\AspNetMVC4Setup.exe"
        ProductId = "942CC691-5B98-42A3-8BC5-A246BA69D983"
        Arguments = "/q"
        DependsOn = "[Package]MVC3"
        Credential = $Credential
    }
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"
}
1
  • It appears that it also can be checked upon by examining result of (Get-WinEvent -LogName "Microsoft-Windows-Dsc/Operational" -ErrorAction SilentlyContinue | ?{ $_.Id -eq "4160" }) I'm not sure that it's much better solution though. – Andrew Savinykh Jun 28 '16 at 5:47
0

Each resource can request the LCM reboot the server. If a resource requests a reboot, it will schedule a reboot and schedule the LCM to run a consistency check after the server reboots (so it can continue configuration).

If you want it to notify you (via the event log or the verbose stream of Start-DscConfiguration) that a reboot is needed, you need to set RebootIfNeeded to $false. Then you are responsible for reboots. Some installers will not run if a reboot is needed to the machine, so this could be a blocker waiting for you to manually reboot the system.

1
  • I was trying that. I thought it was clear since I was quoting the MSDN documentation (btw the flag is called RebootNodeIfNeeded not RebootIfNeeded). Anyway this is the whole point of the post, this does not seem to be working for me – Jupaol Apr 17 '14 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.