locked
Suppressing Restart When Using the Start-WssConfigurationService PowerShell Cmdlet RRS feed

  • Question

  • I'm currently trying to automate deployment of Windows Server 2012 R2 with the Essentials Experience Role by using Desired State Configuration (DSC) in PowerShell.

    I'm hitting two problems when trying to wrap the Essentials setup cmdlets as a DSC resource.

    1. I need to wait for Essentials Role post configuration to complete in the SetResource pass of the DSC resource so I don't prematurely interrupt the Essentials Role post config setup
    2. I need to suppress the automatic restart at the end of the Start-WssConfigurationService cmdlet so I can give the DSC engine a chance to save state and coordiante with other DSC resources in flight before initiating the system restart

    For problem one, I can workaround it by calling Get-WssConfigurationStatus with the ShowProgress parameter after calling Start-WssConfigurationService:

    # Wait for the Essentials Post Install Config
    Get-WssConfigurationStatus –ShowProgress

    For the second problem I've hit a block since Start-WssConfigurationService doesn't have a parameter that will block automatic restartNormally a DSC resource will tell the DSC engine that a restart is required by setting the global PowerShell DSCMachineStatus variable to 1 before letting control leave its SetResource pass. However the automatic restart caused by the Start-WssConfigurationService cmdlet interrupts the DSC engine before it has a chance to receive this flag and save state before it initiates the restart. This breaks the DSC config pass leaving the server in a half configured start after restart.

    Ideally I'd want to be able to use this type of code when calling Start-WssConfigurationService

    # Execute Essentials Post Install Configuration
    $admin = New-Object PSCredential("DomainAdmin",(ConvertTo-SecureString -String "<domain password>" -AsPlainText -Force))
    Start-WssConfigurationService -CompanyName "CC" -DNSName "CC.local" -NetBiosName "CC" -ComputerName "Server” –NewAdminCredential $admin -NoRestart -Wait
    
    # Tell the DSC Engine to restart the machine
    $global:DSCMachineStatus = 1





    • Edited by emed795 Thursday, August 15, 2013 9:07 AM
    Thursday, August 15, 2013 9:02 AM

Answers

All replies