Error: "Define config inside metaconfiguration with this partial config name"

This topic contains 5 replies, has 2 voices, and was last updated by Profile photo of Nitin Gupta Nitin Gupta 5 months, 3 weeks ago.

  • Author
    Posts
  • #42503
    Profile photo of TyMac
    TyMac
    Participant

    I'm trying something new with my configs in order to make them more generic and hopefully more manageable... one base DSC config script that I use different environment data depending on the type of system – for instance:

    Tablet:

    $ConfigurationData = DSC_Config_Data_Tablet_001.psd1

    DSCConfigWkstnBase -output "C:\Configs\Build\$configpath2" -verbose -ConfigurationData $ConfigurationData

    Workstation:

    $ConfigurationData = DSC_Config_Data_Wkstn_001.psd1

    DSCConfigWkstnBase -output "C:\Configs\Build\$configpath2" -verbose -ConfigurationData $ConfigurationData

    Running the first command however seems to not work – I get the error:

    "Configuration DSCConfigTabletBase was pulled from server.
    The partial configuration name DSCConfigWkstnBase present in the configuration document is invalid. Define a
    configuration inside the metaconfiguration with this partial configuration name in order to use it."

    Looks like I cannot do this?

    • This topic was modified 5 months, 3 weeks ago by Profile photo of TyMac TyMac. Reason: grammar
    • This topic was modified 5 months, 3 weeks ago by Profile photo of TyMac TyMac. Reason: grammar
  • #42507
    Profile photo of Nitin Gupta
    Nitin Gupta
    Participant

    Are you getting this error during compilation? From the message it appears that the error would come from LCM rather than compilation. This error indicates that the partial configuration name defined in metaconfiguration doesn't match the one from configuration.

  • #42513
    Profile photo of TyMac
    TyMac
    Participant

    I ran:

    "Update-DscConfiguration -Verbose -Wait"

    on the node LCM and got that error.

    The partial conf mof is named: DSCConfigTabletBase.mof and is DSCConfigTabletBase in the LCM config script.

    The is the contents of DSC_Config_Wkstn_Base_001.ps1 – the DSC config script used to create the mof:

    param
    	(
    		[Parameter(Mandatory = $true)]
    		[string]$ConfigurationData
      )
    
    Configuration DSCConfigWkstnBase {
    
     
        Import-DscResource -Module cWindowsOS -Name cHostsFile
        Import-DscResource -Module xPSDesiredStateConfiguration
        Import-DscResource -Module PackageManagementProviderResource
        Import-DscResource -Module xNetworking
    
    
    
        Node ('localhost') {
            cHostsFile HostsConfig1 {
            IPAddress = $node.IPAddress001
            HostName = $node.HostName001
            Ensure = 'Present'
            }
    
            cHostsFile HostsConfig2 {
            IPAddress = $node.IPAddress002
            HostName = $node.HostName002
            Ensure = 'Present'
            }
            cHostsFile HostsConfig3 {
            IPAddress = $node.IPAddress003
            HostName = $node.HostName003
            Ensure = 'Present'
            }
            
            Registry LogonScreenConfig
            {
                Ensure = "Present"  # You can also set Ensure to "Absent"
                Key = $node.LogonScreenConfigKey
                ValueName = $node.LogonScreenConfigValueName
                ValueData = $node.LogonScreenConfigValueData
                ValueType = $node.LogonScreenConfigValueType
            }
        
            Registry EnableUAC
            {
                Ensure = "Present"  # You can also set Ensure to "Absent"
                Key = $node.EnableUACKey
                ValueName = $node.EnableUACValueName
                ValueData = $node.EnableLUAValueData
                ValueType = $node.EnableLUAValueType
            }
            
            Registry DarkThemeSystem
            {
                Ensure = "Present"  # You can also set Ensure to "Absent"
                Key = $node.DarkThemeSystemKey
                ValueName = $node.DarkThemeSystemValueName
                ValueData = $node.DarkThemeSystemValueData
                ValueType = $node.DarkThemeSystemValueType
            }
            
            PSModule MyPSModule
            {
                Ensure              =   "present"
                Name                =   "PowerShellPushOver"
                InstallationPolicy  =   "trusted"
            }
            PSModule WindowsOS
            {
                Ensure              =   "present"
                Name                =   "cWindowsOS"
                InstallationPolicy  =   "trusted"
            }
            
            PSModule ExcelModule
            {
                Ensure              =   "Present"
                Name                =   "ImportExcel"
                InstallationPolicy  =   "trusted"
            }
            
            PSModule AzureModule
            {
                Ensure              =   "Present"
                Name                =   "Azure"
                InstallationPolicy  =   "trusted"
            }
            
            xDnsServerAddress DnsServerAddress 
            { 
                Address        = $node.DNSAddress001
                InterfaceAlias = $node.InterfaceAlias001
                AddressFamily  = $node.AddressFamily001  
            }
        }
    }
    
    if ($ConfigurationData -eq "..\DSC_Node_Data\DSC_Config_Data_Wkstn_001.ps1") {
    
            $configpath1 = $ConfigurationData.Substring(0,$ConfigurationData.Length-4)
            $configpath2 = $configpath1.Substring(17)
    
            $MOF_Artifact="C:\Configs\Build\$configpath2\localhost.mof"
    
            if (Test-Path $MOF_Artifact){
        
            Remove-Item $MOF_Artifact
        }   
    
    } elseif ($ConfigurationData -eq "..\DSC_Node_Data\DSC_Config_Data_Tablet_001.ps1") {
          
            $configpath1 = $ConfigurationData.Substring(0,$ConfigurationData.Length-4)
            $configpath2 = $configpath1.Substring(17)
    
            $MOF_Artifact="C:\Configs\Build\$configpath2\localhost.mof"
    
            if (Test-Path $MOF_Artifact){
        
            Remove-Item $MOF_Artifact
        } 
    }
    
    $configpath1 = $ConfigurationData.Substring(0,$ConfigurationData.Length-4)
    $configpath2 = $configpath1.Substring(17)
    
    DSCConfigWkstnBase -output "C:\Configs\Build\$configpath2" -verbose -ConfigurationData $ConfigurationData
    
    
  • #42515
    Profile photo of Nitin Gupta
    Nitin Gupta
    Participant

    The configuration name seen by the LCM is not that of the mof file name but the conifguration name from config .ps1 file. In this case it is 'DSCConfigWkstnBase'. However the partial config name defined in the meta configuration seems to be different.
    You have to make sure that partial config name defined in meta configuration matches with the configuration name from config ps1 file.

  • #42574
    Profile photo of TyMac
    TyMac
    Participant

    Ok – adding an extra parameter plus string concatenation seems to have solved my issue:

    param
    	(
    		[Parameter(Mandatory = $true)]
    		[string]$ConfigurationData,
            [Parameter(Mandatory = $true)]
    		[string]$Spec
      )
    
     $configname =  "DSCConfig"+$spec+"Base"
    
    Configuration $configname {
    
     
        Import-DscResource -Module cWindowsOS -Name cHostsFile
        Import-DscResource -Module xPSDesiredStateConfiguration
        Import-DscResource -Module PackageManagementProviderResource
        Import-DscResource -Module xNetworking
    
    
    
        Node ('localhost') {
            cHostsFile HostsConfig1 {
            IPAddress = $node.IPAddress001
            HostName = $node.HostName001
            Ensure = 'Present'
            }
    
            cHostsFile HostsConfig2 {
            IPAddress = $node.IPAddress002
            HostName = $node.HostName002
            Ensure = 'Present'
            }
            cHostsFile HostsConfig3 {
            IPAddress = $node.IPAddress003
            HostName = $node.HostName003
            Ensure = 'Present'
            }
            
            Registry LogonScreenConfig
            {
                Ensure = "Present"  # You can also set Ensure to "Absent"
                Key = $node.LogonScreenConfigKey
                ValueName = $node.LogonScreenConfigValueName
                ValueData = $node.LogonScreenConfigValueData
                ValueType = $node.LogonScreenConfigValueType
            }
        
            Registry EnableUAC
            {
                Ensure = "Present"  # You can also set Ensure to "Absent"
                Key = $node.EnableUACKey
                ValueName = $node.EnableUACValueName
                ValueData = $node.EnableLUAValueData
                ValueType = $node.EnableLUAValueType
            }
            
            Registry DarkThemeSystem
            {
                Ensure = "Present"  # You can also set Ensure to "Absent"
                Key = $node.DarkThemeSystemKey
                ValueName = $node.DarkThemeSystemValueName
                ValueData = $node.DarkThemeSystemValueData
                ValueType = $node.DarkThemeSystemValueType
            }
            
            PSModule MyPSModule
            {
                Ensure              =   "present"
                Name                =   "PowerShellPushOver"
                InstallationPolicy  =   "trusted"
            }
            PSModule WindowsOS
            {
                Ensure              =   "present"
                Name                =   "cWindowsOS"
                InstallationPolicy  =   "trusted"
            }
            
            PSModule ExcelModule
            {
                Ensure              =   "Present"
                Name                =   "ImportExcel"
                InstallationPolicy  =   "trusted"
            }
            
            PSModule AzureModule
            {
                Ensure              =   "Present"
                Name                =   "Azure"
                InstallationPolicy  =   "trusted"
            }
            
            xDnsServerAddress DnsServerAddress 
            { 
                Address        = $node.DNSAddress001
                InterfaceAlias = $node.InterfaceAlias001
                AddressFamily  = $node.AddressFamily001  
            }
        }
    }
    
    if ($ConfigurationData -eq "..\DSC_Node_Data\DSC_Config_Data_Wkstn_001.ps1") {
    
            $configpath1 = $ConfigurationData.Substring(0,$ConfigurationData.Length-4)
            $configpath2 = $configpath1.Substring(17)
    
            $MOF_Artifact="C:\Configs\Build\$configpath2\localhost.mof"
    
            if (Test-Path $MOF_Artifact){
        
            Remove-Item $MOF_Artifact
        }   
    
    } elseif ($ConfigurationData -eq "..\DSC_Node_Data\DSC_Config_Data_Tablet_001.ps1") {
          
            $configpath1 = $ConfigurationData.Substring(0,$ConfigurationData.Length-4)
            $configpath2 = $configpath1.Substring(17)
    
            $MOF_Artifact="C:\Configs\Build\$configpath2\localhost.mof"
    
            if (Test-Path $MOF_Artifact){
        
            Remove-Item $MOF_Artifact
        } 
    }
    
    $configpath1 = $ConfigurationData.Substring(0,$ConfigurationData.Length-4)
    $configpath2 = $configpath1.Substring(17)
    
    $dsc_cmd = "$configname" + " " + "-output" + " " + "C:\Configs\Build\$configpath2" + " " +  "-verbose" + " " +  "-ConfigurationData" + " " + "$ConfigurationData"
    
    Invoke-Expression -command $dsc_cmd
    

    Maybe there is a more elegant way to solve this... ?

    • This reply was modified 5 months, 3 weeks ago by Profile photo of TyMac TyMac.
  • #42578
    Profile photo of Nitin Gupta
    Nitin Gupta
    Participant

    Not a lot of options in this release, hopefully it will be easier to do it in future releases.

You must be logged in to reply to this topic.