Author Posts

May 2, 2017 at 4:46 pm

I have a DSC partial configuration script that I am trying to develop. It fails at the point of configuring the LCM.

Here is the meta config block and script to configure SRV2.

[DSCLocalConfigurationManager()]
Configuration SRV2WebPullPartial {
Node Srv2 {
  Settings
      {  RefreshMode          = 'Pull'
         ConfigurationModeFrequencyMins = 30
         ConfigurationMode    = 'ApplyandAutoCorrect'
         RefreshFrequencyMins = 30 
         RebootNodeIfNeeded   = $true 
         AllowModuleOverwrite = $true }
  ConfigurationRepositoryWeb DSCPullSrv
     {   ServerURL = 'https://SRV1:8080/PSDSCPullServer.svc'
         RegistrationKey = '5d79ee6e-0420-4c98-9cc3-9f696901a816'
         ConfigurationNames = @('NetworkConfig','ServiceConfig')  }
  PartialConfiguration NetworkConfig
     {  Description = 'Network Configuration'
        Configurationsource = @('[ConfigurationRepositoryWeb]DSCPullSrv')}
  PartialConfiguration ServiceConfig {
        Description = 'Service Configuration'
        Configurationsource = @('[ConfigurationRepositoryWeb]DSCPullSrv')
        DependsOn   = '[PartialConfiguration]NetworkConfig'}
  } 
}

# 8. Create MOF to config DSC LCM on SRV2
Remove-Item C:\DSC\* -Rec -Force 
Remove-Item '\\srv2\c$\Windows\System32\Configuration\*.mof'
$Guid = '5d79ee6e-0420-4c98-9cc3-9f696901a816'
SRV2WebPullPartial -OutputPath C:\DSC -Guid $Guid

# 9. Config LCM on SRV2:
$CSSrv2 = New-CimSession -ComputerName SRV2
Set-DscLocalConfigurationManager -CimSession $CSSrv2 `
                                 -Path C:\DSC `
                                 -Verbose


When The last step runs, I get an error:

VERBOSE: Performing the operation "Start-DscConfiguration: SendMetaConfigurationApply" on target "MSFT_DSCLocalConfigurationManager".
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendMetaConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceNam
e' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer SRV2 with user sid S-1-5-21-715049209-2702507345-667613206-500.
VERBOSE: [SRV2]: LCM:  [ Start  Set      ]
VERBOSE: [SRV2]: LCM:  [ Start  Resource ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [SRV2]: LCM:  [ Start  Set      ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [SRV2]: LCM:  [ End    Set      ]  [MSFT_DSCMetaConfiguration]  in 0.0160 seconds.
VERBOSE: [SRV2]: LCM:  [ End    Resource ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [SRV2]: LCM:  [ End    Set      ]
Registration of the Dsc Agent with the server https://SRV1:8080/PSDSCPullServer.svc failed. The underlying error is: The attempt to register Dsc Agent with AgentId 
9CE04E83-1AE3-11E7-836B-B187B8E24E90 with the server https://srv1:8080/PSDSCPullServer.svc/Nodes(AgentId='9CE04E83-1AE3-11E7-836B-B187B8E24E90') returned unexpected response 
code Unauthorized. .
    + CategoryInfo          : InvalidResult: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : RegisterDscAgentUnsuccessful,Microsoft.PowerShell.DesiredStateConfiguration.Commands.RegisterDscAgentCommand
    + PSComputerName        : SRV2
 
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Set-DscLocalConfigurationManager finished in 29.855 seconds.

I'm sure I'm making a silly mistake, but I just can't see it., Clues??

May 3, 2017 at 11:55 am

Hello!

Why do you use both GUID and Configuration names ?

Try to run this directly on your node:

[DSCLocalConfigurationManager()]
Configuration SRV2WebPullPartial {
Node Srv2 {
  Settings
      {  RefreshMode          = 'Pull'
         ConfigurationModeFrequencyMins = 30
         ConfigurationMode    = 'ApplyandAutoCorrect'
         RefreshFrequencyMins = 30 
         RebootNodeIfNeeded   = $true 
         AllowModuleOverwrite = $true }
  ConfigurationRepositoryWeb DSCPullSrv
     {   ServerURL = 'https://SRV1:8080/PSDSCPullServer.svc'
         RegistrationKey = '5d79ee6e-0420-4c98-9cc3-9f696901a816'
         ConfigurationNames = @('NetworkConfig','ServiceConfig')  }
  PartialConfiguration NetworkConfig
     {  Description = 'Network Configuration'
        Configurationsource = @('[ConfigurationRepositoryWeb]DSCPullSrv')}
  PartialConfiguration ServiceConfig {
        Description = 'Service Configuration'
        Configurationsource = @('[ConfigurationRepositoryWeb]DSCPullSrv')
        DependsOn   = '[PartialConfiguration]NetworkConfig'}
  } 
}
SRV2WebPullPartial
Set-DSCLocalConfigurationManager localhost –Path .\SRV2WebPullPartial –Verbose -Force