CR for Log Enabling

Hello, So after finding the xWinEvent resource I’m working on a composite resource to get this out. Here’s what I’ve got:

Configuration rDSCLogging
{
	Param(
	[Parameter(Mandatory = $true)]
	[string]$Logname,

	[Parameter(Mandatory = $true)]
	[bool]$setstatus
	)
	
	Import-DscResource -module xWinEventLog
	
	$loghalf = "Microsoft-Windows-WMI-Activity/"
	{
		xWinEventLog WMILog
		{
			Logname = $loghalf + $LogName
			IsEnabled = $setstatus
			Logmode = "Circular"
			MaximumSizeInBytes = 5mb
		}
	}
}

and I am trying to call this resource like so in my main configuration:

 
Configuration SQLinstall 
{
    Import-DscResource -name *
 
    Node $allnodes.where({$_.NodeRole -eq "SQL"}).NodeGuid {
        rDSCLogging EnableAnalyticSQL {
            Logname = "Analytic"
            setstatus = $enabled }
              
        rdsclogging EnableDebugSQL {
            Logname = "Debug"
            setstatus = $enabled }    
 }             
} 

Powershell is giving me this error output, likely because I am still newb to paramaters:

SQLInstall -ConfigurationData $AllServerConfigData -outpath "C:\contoso\WorkDir"

PSDesiredStateConfiguration\Node : Cannot convert value "" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 
0.
At line:95 char:5
+     Node $allnodes.where({$_.NodeRole -eq "SQL"}).NodeGuid {
+     ~~~~
    + CategoryInfo          : InvalidArgument: (:) [PSDesiredStateConfiguration\node], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidCastExceptionUnsupportedParameterType,PSDesiredStateConfiguration\node
 
PSDesiredStateConfiguration\Node : Cannot convert value "" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 
0.
At line:95 char:5
+     Node $allnodes.where({$_.NodeRole -eq "SQL"}).NodeGuid {
+     ~~~~
    + CategoryInfo          : InvalidArgument: (:) [PSDesiredStateConfiguration\node], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidCastExceptionUnsupportedParameterType,PSDesiredStateConfiguration\node
 
PSDesiredStateConfiguration\Node : Cannot convert value "" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 
0.
At line:95 char:5
+     Node $allnodes.where({$_.NodeRole -eq "SQL"}).NodeGuid {
+     ~~~~
    + CategoryInfo          : InvalidArgument: (:) [PSDesiredStateConfiguration\node], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidCastExceptionUnsupportedParameterType,PSDesiredStateConfiguration\node
 
Errors occurred while processing configuration 'SQLinstall'.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2223 char:5
+     throw $errorRecord
+     ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (SQLinstall:String) [], InvalidOperationException
    + FullyQualifiedErrorId : FailToProcessConfiguration

Configuration data is populated with computers from AD, and is proven to work with other configs.

What is in your $enabled variable? That’s the only place I can see that you might be running into trouble with a conversion to Boolean.

Thanks as always for the reply Dave! The situation has changed just a bit, now the script works IF I specify a node in the configuration. If I do not, then when I try to use $allnodes.Where({$_.NodeRole -eq "sql}).nodeguid tied into -configurationdata the command is taken but no MOFs are generated.

Updated composite resource: (DSCLogging.schema.psm1)

Configuration rDSCLogging
{
	Param (
		[Parameter(Mandatory = $true)]
		[validateset('Analytic', 'Operational', 'Debug')]
		[string]$Logname,
		
		[Parameter(Mandatory = $true)]
		[string]$setstatus
	)
	
	switch ($setstatus)
	{
		'Enable' { $true }
		'Enabled' { $true }
		'Disable' { $false }
		'Disabled' { $false }
		default { $false }
	}
	Import-DscResource -module xWinEventLog
	
	$loghalf = "Microsoft-Windows-WMI-Activity/"
#	node Localhost
	{
		xWinEventLog WMILog
		{
			Logname = $loghalf + $LogName
			IsEnabled = $setstatus
			Logmode = "Circular"
			MaximumSizeInBytes = 5mb
		}
	}
}

Updated masterconfig entry:

Configuration SQLinstall 
{
    Import-DscResource -name *
 
    Node $allnodes.where({$_.NodeRole -eq "SQL"}).NodeGuid {
        rDSCLogging EnableAnalyticSQL {
            Logname = "Analytic"
            setstatus = "Enabled" }
              
        rdsclogging EnableDebugSQL {
            Logname = "Debug"
            setstatus = "Enabled" }    
 }             
}

SQLInstall -ConfigurationData $AllServerConfigData -outpath "C:\Contoso\WorkDir"

Isn’t it strange that it’ll make me a perfect MOF if I specify the node but I can’t feed configurationdata to it?