PowerShell / PowerShell

PowerShell for every system!
https://microsoft.com/PowerShell
MIT License
45.59k stars 7.31k forks source link

DSC Push mode: DSC does not wait for reboots to complete in all cases #2792

Closed JohnLudlow closed 1 year ago

JohnLudlow commented 7 years ago

Steps to reproduce

  1. Prepare two machines (not domain joined) with supported versions of Windows and PowerShell 5.1
    • One will be the 'DC' machine. the other will be the domain client
    • Configure the LCMs like so:
Configuration DscLcmConfiguration {
  Node $AllNodes.Where{$_.NodeName -notin "*","localhost"}.NodeName
  {
    Settings {
      DebugMode            = "ForceModuleImport"
      CertificateId        = $node.thumbprint
      ActionAfterReboot    = 'ContinueConfiguration'
      AllowModuleOverwrite = $true
      RebootNodeIfNeeded   = $true
   }
  }
}
  1. Define a configuration which

    • uses xADDomain to configure a domain on the 'DC'
    • uses DependsOn/WaitForAll or xWaitForDomain to wait for the previous resource to complete
    • uses xComputer to join the other computer to the new domain
    • uses DependsOn/WaitForAll to wait for the previous resource to complete
    • uses some other resource which depends on xComputer. Doesn't really matter which one, but WindowsProcess might be a good choice
  2. Compile and apply the configuration using Start-DscConfiguration -Path .\Path\To\MOFs\ -Force -Verbose -Wait

Expected behavior

  1. The domain is configured, and the DC machine is rebooted because the resource sets $global:DSCMachineStatus = 1. DSC waits for the reboot to complete before continuing

  2. The other machine is joined to the domain and is rebooted because the resource sets $global:DSCMachineStatus = 1. DSC waits for the reboot to complete before continuing

  3. The final resource is triggered to prove that DSC waited for the reboots to complete

Actual behavior

  1. The domain is configured, and the DC machine is rebooted because the resource sets $global:DSCMachineStatus = 1. DSC waits for the reboot to complete before continuing

  2. The other machine is joined to the domain but is not rebooted immediately. DSC declares the machine 'configured' and carries on.

    If I log onto this machine and check the state of the LCM, it will be in one of these states:

    • Performing a consistency check
    • Waiting for a pending reboot
    • Applying a configuration after reboot
    • Idle after completing the configuration

    However, the overall configuration does not wait for this to complete

  3. The final resource is skipped, though after a while (15 minutes, I guess) the machine is rebooted, the consistency check is performed and the configuration is applied.

Some things to note

PS C:\Users\Administrator> wevtutil.exe set-log “Microsoft-Windows-Dsc/Analytic” /q:true /e:true
The channel fails to activate.

Failed to save configuration or activate log Microsoft-Windows-Dsc/Analytic. The requested operation cannot be performed
 over an enabled direct channel. The channel must first be disabled before performing the requested operation.

That sort of threw me and I wasn't sure how to proceed. However, I have attached the Operational log (actually the .zip you can get from xDscDiagnostics)

cvtdmofh.zge-20161125065616.zip

Environment data

> $PSVersionTable

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.14394.1000                                                                          
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.14394.1000                                                                         
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 

The DSC resources available on that system:


ImplementedAs   Name                      ModuleName                     Version    Properties                         
-------------   ----                      ----------                     -------    ----------                         
Binary          File                                                                {DestinationPath, Attributes, Ch...
Binary          SignatureValidation                                                 {SignedItemType, TrustedStorePath} 
PowerShell      VTAS_cEsxVirtualMachin... ManageVM                       1.0        {Credential, PowerState, Server,...
PowerShell      VTAS_cEsxVirtualMachin... ManageVM                       1.0        {Credential, Server, SnapShotNam...
PowerShell      Archive                   PSDesiredStateConfiguration    1.1        {Destination, Path, Checksum, Cr...
PowerShell      Environment               PSDesiredStateConfiguration    1.1        {Name, DependsOn, Ensure, Path...} 
PowerShell      Group                     PSDesiredStateConfiguration    1.1        {GroupName, Credential, DependsO...
Composite       GroupSet                  PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential...
Binary          Log                       PSDesiredStateConfiguration    1.1        {Message, DependsOn, PsDscRunAsC...
PowerShell      Package                   PSDesiredStateConfiguration    1.1        {Name, Path, ProductId, Argument...
Composite       ProcessSet                PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential...
PowerShell      Registry                  PSDesiredStateConfiguration    1.1        {Key, ValueName, DependsOn, Ensu...
PowerShell      Script                    PSDesiredStateConfiguration    1.1        {GetScript, SetScript, TestScrip...
PowerShell      Service                   PSDesiredStateConfiguration    1.1        {Name, BuiltInAccount, Credentia...
Composite       ServiceSet                PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential...
PowerShell      User                      PSDesiredStateConfiguration    1.1        {UserName, DependsOn, Descriptio...
PowerShell      WaitForAll                PSDesiredStateConfiguration    1.1        {NodeName, ResourceName, Depends...
PowerShell      WaitForAny                PSDesiredStateConfiguration    1.1        {NodeName, ResourceName, Depends...
PowerShell      WaitForSome               PSDesiredStateConfiguration    1.1        {NodeCount, NodeName, ResourceNa...
PowerShell      WindowsFeature            PSDesiredStateConfiguration    1.1        {Name, Credential, DependsOn, En...
Composite       WindowsFeatureSet         PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential...
PowerShell      WindowsOptionalFeature    PSDesiredStateConfiguration    1.1        {Name, DependsOn, Ensure, LogLev...
Composite       WindowsOptionalFeatureSet PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential...
PowerShell      WindowsPackageCab         PSDesiredStateConfiguration    1.1        {Ensure, Name, SourcePath, Depen...
PowerShell      WindowsProcess            PSDesiredStateConfiguration    1.1        {Arguments, Path, Credential, De...
PowerShell      TrustedHost               TrustedHostResource            1.0.0.1    {Name, DependsOn, Ensure, PsDscR...
PowerShell      xADComputer               xActiveDirectory               2.13.0.0   {ComputerName, DependsOn, Descri...
PowerShell      xADComputer               xActiveDirectory               2.14.0.0   {ComputerName, DependsOn, Descri...
PowerShell      xADDomain                 xActiveDirectory               2.13.0.0   {DomainAdministratorCredential, ...
PowerShell      xADDomain                 xActiveDirectory               2.14.0.0   {DomainAdministratorCredential, ...
PowerShell      xADDomainController       xActiveDirectory               2.13.0.0   {DomainAdministratorCredential, ...
PowerShell      xADDomainController       xActiveDirectory               2.14.0.0   {DomainAdministratorCredential, ...
PowerShell      xADDomainDefaultPasswo... xActiveDirectory               2.14.0.0   {DomainName, ComplexityEnabled, ...
PowerShell      xADDomainDefaultPasswo... xActiveDirectory               2.13.0.0   {DomainName, ComplexityEnabled, ...
PowerShell      xADDomainTrust            xActiveDirectory               2.14.0.0   {SourceDomainName, TargetDomainA...
PowerShell      xADDomainTrust            xActiveDirectory               2.13.0.0   {SourceDomainName, TargetDomainA...
PowerShell      xADGroup                  xActiveDirectory               2.14.0.0   {GroupName, Category, Credential...
PowerShell      xADGroup                  xActiveDirectory               2.13.0.0   {GroupName, Category, Credential...
PowerShell      xADOrganizationalUnit     xActiveDirectory               2.13.0.0   {Name, Path, Credential, Depends...
PowerShell      xADOrganizationalUnit     xActiveDirectory               2.14.0.0   {Name, Path, Credential, Depends...
PowerShell      xADRecycleBin             xActiveDirectory               2.13.0.0   {EnterpriseAdministratorCredenti...
PowerShell      xADRecycleBin             xActiveDirectory               2.14.0.0   {EnterpriseAdministratorCredenti...
PowerShell      xADUser                   xActiveDirectory               2.13.0.0   {DomainName, UserName, CannotCha...
PowerShell      xADUser                   xActiveDirectory               2.14.0.0   {DomainName, UserName, CannotCha...
PowerShell      xWaitForADDomain          xActiveDirectory               2.13.0.0   {DomainName, DependsOn, DomainUs...
PowerShell      xWaitForADDomain          xActiveDirectory               2.14.0.0   {DomainName, DependsOn, DomainUs...
PowerShell      xComputer                 xComputerManagement            1.8.0.0    {Name, Credential, DependsOn, Do...
PowerShell      xOfflineDomainJoin        xComputerManagement            1.8.0.0    {IsSingleInstance, RequestFile, ...
PowerShell      xScheduledTask            xComputerManagement            1.8.0.0    {ActionExecutable, RepeatInterva...
PowerShell      VTAS_xADDomain            xDscUtil                       1.0.0.6    {Credential, DomainName, DomainN...
PowerShell      VTAS_xComputerName        xDscUtil                       1.0.0.6    {ComputerName, Credential, NewCo...
PowerShell      VTAS_xMountIso            xDscUtil                       1.0.0.6    {DriveLetter, IsoPath, DependsOn...
PowerShell      VTAS_xRemotePfxImport     xDscUtil                       1.0.0.6    {CertificateStorePath, ComputerN...
PowerShell      VTAS_xTrustedHost         xDscUtil                       1.0.0.6    {HostName, DependsOn, Ensure, Ps...
PowerShell      VTAS_xEsxVirtualMachine   xEsxUtil                       2.0.0.0    {Credential, VCenterComputerName...
PowerShell      VTAS_xEsxVirtualMachin... xEsxUtil                       2.0.0.0    {EsxCredential, VCenterComputerN...
PowerShell      VTAS_xEsxVirtualMachin... xEsxUtil                       2.0.0.0    {EsxCredential, VCenterComputerN...
PowerShell      VTAS_xEsxVirtualMachin... xEsxUtil                       2.0.0.0    {Credential, PowerState, VCenter...
PowerShell      VTAS_xEsxVirtualMachin... xEsxUtil                       2.0.0.0    {EsxCredential, VCenterComputerN...
PowerShell      xExchActiveSyncVirtual... xExchange                      1.10.0.0   {Credential, Identity, AllowServ...
PowerShell      xExchAntiMalwareScanning  xExchange                      1.10.0.0   {Credential, Enabled, AllowServi...
PowerShell      xExchAutodiscoverVirtu... xExchange                      1.10.0.0   {Credential, Identity, AllowServ...
PowerShell      xExchAutoMountPoint       xExchange                      1.10.0.0   {AutoDagDatabasesRootFolderPath,...
PowerShell      xExchClientAccessServer   xExchange                      1.10.0.0   {Credential, Identity, AutoDisco...
PowerShell      xExchDatabaseAvailabil... xExchange                      1.10.0.0   {AutoDagTotalNumberOfServers, Cr...
PowerShell      xExchDatabaseAvailabil... xExchange                      1.10.0.0   {Credential, DAGName, MailboxSer...
PowerShell      xExchDatabaseAvailabil... xExchange                      1.10.0.0   {Credential, DatabaseAvailabilit...
PowerShell      xExchEcpVirtualDirectory  xExchange                      1.10.0.0   {Credential, Identity, AdfsAuthe...
PowerShell      xExchEventLogLevel        xExchange                      1.10.0.0   {Credential, Identity, Level, De...
PowerShell      xExchExchangeCertificate  xExchange                      1.10.0.0   {Credential, Ensure, Thumbprint,...
PowerShell      xExchExchangeServer       xExchange                      1.10.0.0   {Credential, Identity, AllowServ...
PowerShell      xExchImapSettings         xExchange                      1.10.0.0   {Credential, Server, AllowServic...
PowerShell      xExchInstall              xExchange                      1.10.0.0   {Arguments, Credential, Path, De...
PowerShell      xExchJetstress            xExchange                      1.10.0.0   {JetstressParams, JetstressPath,...
PowerShell      xExchJetstressCleanup     xExchange                      1.10.0.0   {JetstressPath, ConfigFilePath, ...
PowerShell      xExchMailboxDatabase      xExchange                      1.10.0.0   {Credential, DatabaseCopyCount, ...
PowerShell      xExchMailboxDatabaseCopy  xExchange                      1.10.0.0   {Credential, Identity, MailboxSe...
PowerShell      xExchMailboxServer        xExchange                      1.10.0.0   {Credential, Identity, DatabaseC...
PowerShell      xExchMailboxTransportS... xExchange                      1.10.0.0   {Credential, Identity, AllowServ...
PowerShell      xExchMaintenanceMode      xExchange                      1.10.0.0   {Credential, Enabled, Additional...
PowerShell      xExchMapiVirtualDirectory xExchange                      1.10.0.0   {Credential, Identity, IISAuthen...
PowerShell      xExchOabVirtualDirectory  xExchange                      1.10.0.0   {Credential, Identity, AllowServ...
PowerShell      xExchOutlookAnywhere      xExchange                      1.10.0.0   {Credential, Identity, AllowServ...
PowerShell      xExchOwaVirtualDirectory  xExchange                      1.10.0.0   {Credential, Identity, AdfsAuthe...
PowerShell      xExchPopSettings          xExchange                      1.10.0.0   {Credential, Server, AllowServic...
PowerShell      xExchPowerShellVirtual... xExchange                      1.10.0.0   {Credential, Identity, AllowServ...
PowerShell      xExchReceiveConnector     xExchange                      1.10.0.0   {Credential, Ensure, Identity, A...
PowerShell      xExchTransportService     xExchange                      1.10.0.0   {Credential, Identity, ActiveUse...
PowerShell      xExchUMCallRouterSettings xExchange                      1.10.0.0   {Credential, Server, UMStartupMo...
PowerShell      xExchUMService            xExchange                      1.10.0.0   {Credential, Identity, UMStartup...
PowerShell      xExchWaitForADPrep        xExchange                      1.10.0.0   {Identity, Credential, DependsOn...
PowerShell      xExchWaitForDAG           xExchange                      1.10.0.0   {Credential, Identity, DependsOn...
PowerShell      xExchWaitForMailboxDat... xExchange                      1.10.0.0   {Credential, Identity, AdServerS...
PowerShell      xExchWebServicesVirtua... xExchange                      1.10.0.0   {Credential, Identity, AllowServ...
PowerShell      xDefaultGatewayAddress    xNetworking                    2.12.0.0   {AddressFamily, InterfaceAlias, ...
PowerShell      xDefaultGatewayAddress    xNetworking                    3.0.0.0    {AddressFamily, InterfaceAlias, ...
PowerShell      xDHCPClient               xNetworking                    2.12.0.0   {AddressFamily, InterfaceAlias, ...
PowerShell      xDHCPClient               xNetworking                    3.0.0.0    {AddressFamily, InterfaceAlias, ...
PowerShell      xDnsClientGlobalSetting   xNetworking                    3.0.0.0    {IsSingleInstance, DependsOn, De...
PowerShell      xDnsClientGlobalSetting   xNetworking                    2.12.0.0   {IsSingleInstance, DependsOn, De...
PowerShell      xDnsConnectionSuffix      xNetworking                    2.12.0.0   {ConnectionSpecificSuffix, Inter...
PowerShell      xDnsConnectionSuffix      xNetworking                    3.0.0.0    {ConnectionSpecificSuffix, Inter...
PowerShell      xDNSServerAddress         xNetworking                    3.0.0.0    {Address, AddressFamily, Interfa...
PowerShell      xDNSServerAddress         xNetworking                    2.12.0.0   {Address, AddressFamily, Interfa...
PowerShell      xFirewall                 xNetworking                    3.0.0.0    {Name, Action, Authentication, D...
PowerShell      xFirewall                 xNetworking                    2.12.0.0   {Name, Action, Authentication, D...
PowerShell      xHostsFile                xNetworking                    3.0.0.0    {HostName, DependsOn, Ensure, IP...
PowerShell      xHostsFile                xNetworking                    2.12.0.0   {HostName, DependsOn, Ensure, IP...
PowerShell      xIPAddress                xNetworking                    2.12.0.0   {InterfaceAlias, IPAddress, Addr...
PowerShell      xIPAddress                xNetworking                    3.0.0.0    {InterfaceAlias, IPAddress, Addr...
PowerShell      xNetAdapterBinding        xNetworking                    3.0.0.0    {ComponentId, InterfaceAlias, De...
PowerShell      xNetAdapterBinding        xNetworking                    2.12.0.0   {ComponentId, InterfaceAlias, De...
PowerShell      xNetBIOS                  xNetworking                    2.12.0.0   {InterfaceAlias, Setting, Depend...
PowerShell      xNetBIOS                  xNetworking                    3.0.0.0    {InterfaceAlias, Setting, Depend...
PowerShell      xNetConnectionProfile     xNetworking                    3.0.0.0    {InterfaceAlias, DependsOn, IPv4...
PowerShell      xNetConnectionProfile     xNetworking                    2.12.0.0   {InterfaceAlias, DependsOn, IPv4...
PowerShell      xNetworkTeam              xNetworking                    3.0.0.0    {Name, TeamMembers, DependsOn, E...
PowerShell      xNetworkTeam              xNetworking                    2.12.0.0   {Name, TeamMembers, DependsOn, E...
PowerShell      xNetworkTeamInterface     xNetworking                    3.0.0.0    {Name, TeamName, DependsOn, Ensu...
PowerShell      xNetworkTeamInterface     xNetworking                    2.12.0.0   {Name, TeamName, DependsOn, Ensu...
PowerShell      xRoute                    xNetworking                    2.12.0.0   {AddressFamily, DestinationPrefi...
PowerShell      xRoute                    xNetworking                    3.0.0.0    {AddressFamily, DestinationPrefi...
PowerShell      xPendingReboot            xPendingReboot                 0.3.0.0    {Name, DependsOn, PsDscRunAsCred...
PowerShell      xRemoteDesktopAdmin       xRemoteDesktopAdmin            1.1.0.0    {Ensure, DependsOn, PsDscRunAsCr...
PowerShell      xSmbShare                 xSmbShare                      2.0.0.0    {Name, Path, ChangeAccess, Concu...
PowerShell      xSQLAlias                 xSQLServer                     3.0.0.0    {Name, ServerName, DependsOn, En...
PowerShell      xSQLAOGroupEnsure         xSQLServer                     3.0.0.0    {AvailabilityGroupName, Ensure, ...
PowerShell      xSQLAOGroupJoin           xSQLServer                     3.0.0.0    {AvailabilityGroupName, Ensure, ...
PowerShell      xSQLDatabaseRecoveryModel xSQLServer                     3.0.0.0    {DatabaseName, RecoveryModel, Sq...
PowerShell      xSQLServerAlwaysOnService xSQLServer                     3.0.0.0    {Ensure, DependsOn, PsDscRunAsCr...
PowerShell      xSQLServerAvailability... xSQLServer                     3.0.0.0    {AvailabilityGroup, InstanceName...
PowerShell      xSQLServerConfiguration   xSQLServer                     3.0.0.0    {InstanceName, OptionName, Optio...
PowerShell      xSQLServerDatabase        xSQLServer                     3.0.0.0    {Name, SQLInstanceName, SQLServe...
PowerShell      xSQLServerDatabaseOwner   xSQLServer                     3.0.0.0    {Database, Name, DependsOn, PsDs...
PowerShell      xSQLServerDatabasePerm... xSQLServer                     3.0.0.0    {Database, Name, Permissions, De...
PowerShell      xSQLServerDatabaseRole    xSQLServer                     3.0.0.0    {Database, Name, Role, DependsOn...
PowerShell      xSQLServerEndpoint        xSQLServer                     3.0.0.0    {EndPointName, AuthorizedUser, D...
PowerShell      xSQLServerEndpointPerm... xSQLServer                     3.0.0.0    {InstanceName, Name, NodeName, P...
PowerShell      xSQLServerEndpointState   xSQLServer                     3.0.0.0    {InstanceName, Name, NodeName, D...
PowerShell      xSQLServerFailoverClus... xSQLServer                     3.0.0.0    {Action, FailoverClusterNetworkN...
PowerShell      xSQLServerFirewall        xSQLServer                     3.0.0.0    {Features, InstanceName, Depends...
PowerShell      xSQLServerLogin           xSQLServer                     3.0.0.0    {Name, SQLInstanceName, SQLServe...
PowerShell      xSQLServerMaxDop          xSQLServer                     3.0.0.0    {SQLInstanceName, DependsOn, Dyn...
PowerShell      xSQLServerMemory          xSQLServer                     3.0.0.0    {DynamicAlloc, SQLInstanceName, ...
PowerShell      xSQLServerNetwork         xSQLServer                     3.0.0.0    {InstanceName, ProtocolName, Dep...
PowerShell      xSQLServerPermission      xSQLServer                     3.0.0.0    {InstanceName, NodeName, Princip...
PowerShell      xSQLServerPowerPlan       xSQLServer                     3.0.0.0    {Ensure, DependsOn, PsDscRunAsCr...
PowerShell      xSQLServerReplication     xSQLServer                     3.0.0.0    {AdminLinkCredentials, Distribut...
PowerShell      xSQLServerRole            xSQLServer                     3.0.0.0    {Name, ServerRole, SQLInstanceNa...
PowerShell      xSQLServerRSConfig        xSQLServer                     3.0.0.0    {InstanceName, RSSQLInstanceName...
PowerShell      xSQLServerRSSecureConn... xSQLServer                     3.0.0.0    {InstanceName, SecureConnectionL...
PowerShell      xSQLServerScript          xSQLServer                     3.0.0.0    {GetFilePath, ServerInstance, Se...
PowerShell      xSQLServerSetup           xSQLServer                     3.0.0.0    {InstanceName, SetupCredential, ...
PowerShell      xWaitForAvailabilityGroup xSQLServer                     3.0.0.0    {Name, DependsOn, PsDscRunAsCred...
JohnLudlow commented 7 years ago

BTW, if any more information is required, please just ask

Thanks!

SteveL-MSFT commented 7 years ago

CC @grayzu @nanalakshmanan

ghost commented 3 years ago

For others reference, perhaps your own, but, given the elapsed, time... try disabling the Analytic or Debug log first:

Disable the Analytic and Debug Logs

wevtutil.exe set-log "Microsoft-Windows-Dsc/Analytic" /q:true /e:false wevtutil.exe set-log "Microsoft-Windows-Dsc/Debug" /q:True /e:false

Enable Analytic and Debug Logs

wevtutil.exe set-log "Microsoft-Windows-Dsc/Analytic" /q:true /e:true wevtutil.exe set-log "Microsoft-Windows-Dsc/Debug" /q:True /e:true

IT WORKS FOR ME

jburbach99 commented 3 years ago

Th NA

ThomasNieto commented 1 year ago

@StevenBucher98 can this issue be closed since the LCM isn't in this repository?