# CR for Log Enabling

**URL:** https://forums.powershell.org/t/cr-for-log-enabling/3500
**Category:** DSC
**Created:** [December 9, 2014, 4:36am UTC](https://forums.powershell.org/t/cr-for-log-enabling/3500 "2014-12-09T04:36:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ryan-young](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ryan-young](https://forums.powershell.org/u/ryan-young)
#### Post date: [December 9, 2014, 4:36am UTC](https://forums.powershell.org/t/cr-for-log-enabling/3500/1 "2014-12-09T04:36:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)
#### Post date: [December 9, 2014, 6:57am UTC](https://forums.powershell.org/t/cr-for-log-enabling/3500/2 "2014-12-09T06:57:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ryan-young](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ryan-young](https://forums.powershell.org/u/ryan-young)
#### Post date: [December 9, 2014, 9:26am UTC](https://forums.powershell.org/t/cr-for-log-enabling/3500/3 "2014-12-09T09:26:24Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)
#### Post date: [May 16, 2024, 9:17pm UTC](https://forums.powershell.org/t/cr-for-log-enabling/3500/4 "2024-05-16T21:17:28Z")

</div>


