Reboot is required but does not happen

This topic contains 5 replies, has 4 voices, and was last updated by Profile photo of Michael Felkins Michael Felkins 2 years, 1 month ago.

  • Author
    Posts
  • #19624
    Profile photo of Michael Felkins
    Michael Felkins
    Participant

    Hi,

    I have a DSC script that installs IIS on a 2008R2 server. Rather than install the whole IIS role, we pick an choose the features we want. After the features are all installed, I go ahead and configure the web sites.

    What I am finding is that the script fails when I am configuring the apppools. However if I reboot the server and rerun the script, it runs all the way through with no errors.

    How can I force a reboot after the feature install and have the script pick up where it left off or even just start over. Either way would work for me.

    I added the xPendingReboot module from the latest wave, right after the WindowsFeature module but that just skips on through.'

    WindowsFeature as-was-support
    {
    Name = "as-was-support"
    Ensure = "Present"
    # Source = $Source
    }

    # Needs restart

    xPendingReboot Reboot1
    {
    Name = 'BeforeSoftwareInstall'
    }
    LocalConfigurationManager
    {
    RebootNodeIfNeeded = 'True'
    }

    OldDog

  • #19625
    Profile photo of Don Jones
    Don Jones
    Keymaster

    I don't think you can do that using the built-in WindowsFeature resource; you'd need to build a custom one. The provided resource only sets the reboot flag if Install-WindowsFeature indicates that a reboot is required. If that cmdlet doesn't indicate a needed reboot, there won't be one.

    xPendingReboot only acts on a pending reboot; it doesn't trigger a pending reboot.

  • #19628
    Profile photo of Michael Felkins
    Michael Felkins
    Participant

    OK,

    My next thought is to set up a PS script to
    1. Run the DSC script,
    2. set the RunOnceKey to start the DSC script again
    3. Restart the server
    3. Hope for the best, plan for the worst.

    OldDog

  • #19633
    Profile photo of Kamran Safavi
    Kamran Safavi
    Participant

    In a custom DSC resource, I believe setting $global:DSCMachineStatus = 1 in the Set-TargetResource function will force a reboot,

  • #19662
    Profile photo of David O'Brien
    David O’Brien
    Participant

    It will only force a reboot if that is set in the Local Configuration Manager properties.

    Something like this:

    
    configuration LCM {
    
        Node localhost
            {
    
                LocalConfigurationManager
                    {
                        RebootNodeIfNeeded = $true
                    }
            }
    }

    Cheers,
    David

  • #19934
    Profile photo of Michael Felkins
    Michael Felkins
    Participant

    Hi,

    Looks like what really is happening is that I need to run an iisreset once or twice to get the script to go all the way through with out errors.

    I'll start another tread about that.

    OldDog

You must be logged in to reply to this topic.