Registering a target node using a configuration ID

Note how this is a similar DSC configuration script to any we have used so far until we get to the LocalConfigurationManager keyword. We use this keyword to configure the local LCM to operate how we want it to:

Configuration ConfigurationIDTargetNodeLCM
{
  Node $AllNodes.Where({ $_.Roles -contains 'Target'}).NodeName
  {
    LocalConfigurationManager
    {
      ConfigurationId     = $Node.ConfigurationId
      RefreshMode         = $Node.RefreshMode
      ConfigurationMode   = $Node.ConfigurationMode
      DownloadManagerName = 'WebDownloadManager'
      DownloadManagerCustomData = @{
        ServerURL     = $Node.ConfigurationServerURL
        CertificateID = $Node.CertificateID
} } } }

We use the same configuration data script that we used to create the DSC pull server here, but you can choose to have different data files or keep the same. We'll invoke this just like we did with the DSC pull server using a wrapper script, as shown here:

$outputPath = ([IO.Path]::Combine($PSScriptRoot, 'WMF4TargetNodeLCM'))
$dataScript = ([IO.Path]::Combine($PSScriptRoot, 'wmf4_config_data.ps1'))
$configData = &$dataScript
    
C:vagrantconfigurationid_target_node.ps1 -configdata $configData `
-output $outputPath Set-DscLocalConfigurationManager -Path $outputPath -Verbose

This step only needs to be done once per target node; after this, the DSC pull server can handle any changes you might need to make.

When we want to apply these settings to the LCM, we use the Set-DscLocalConfigurationManager cmdlet. This cmdlet behaves like Start-DscConfiguration in that it can operate both locally and remotely and can operate on as many machines as desired at the same time:

[PS]> C:vagrant3_install_target_node.ps1
    
        Directory: C:vagrantookch06WMF4TargetNodeLCM
    
    Mode                LastWriteTime     Length Name
    ----                -------------     ------ ----
    -----         9/19/2015   9:27 AM       1840 dsc-box2.meta.mof
VERBOSE: Performing the operation "Start-DscConfiguration: SendMetaConfigurationApply" on target
    "MSFT_DSCLocalConfigurationManager".
    VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' =
    SendMetaConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' =
    root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer DSC-BOX1 with user sid
    S-1-5-21-2584411961-1507261911-1533134791-1001.
VERBOSE: [DSC-BOX2]: LCM:  [ Start  Set      ]
VERBOSE: [DSC-BOX2]: LCM:  [ Start  Resource ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [DSC-BOX2]: LCM:  [ Start  Set      ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [DSC-BOX2]: LCM:  [ End    Set      ]  [MSFT_DSCMetaConfiguration]  in 0.0400 seconds.
VERBOSE: [DSC-BOX2]: LCM:  [ End    Resource ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [DSC-BOX2]: LCM:  [ End    Set      ]    in  0.0922 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Set-DscLocalConfigurationManager finished in 0.146 seconds.  
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset