I went the route of creating a composite resource for each action: enable analytic, enable debug, disable analytic, disable debug with a resource.schema.psm1 file containing something to the effect of:
configuration rDisableDSCDebugLog { Script DisableDscDebug { GetScript = { #Do Nothing } SetScript = { $DisableDebug = "wevtutil sl Microsoft-Windows-DSC/Debug /e:false" Invoke-Expression $DisableDebug | Write-Verbose } TestScript = { $false } } }
It seems to work to disable my logging but not to enable it (which is strange?) An example of an enable is:
Configuration rEnableDSCDebugLog { Script EnableDscDebug { GetScript = { #Do Nothing } SetScript = { $EnableDebug = "wevtutil sl Microsoft-Windows-DSC/Debug /e:true" Invoke-Expression $EnableDebug | Write-Verbose } TestScript = { $false } } }
Bottom line, how do you guys go about enabling/disabling DSC logging on your nodes? I know there’s the xdscdiagnostics command for Update-xDscEventLogStatus that I ‘could’ run remotely from my pull server, but I kind of want the flexibility to have this apply to only hosts who are members of certain configurations, roles, or environments (which is why I was looking for a solution to include the change as part of the configuration section like so):
Configuration SQLinstall { Import-DscResource -name * Node $allnodes.where({$_.NodeRole -eq "SQL"}).NodeGuid { renableDSCAnalyticLog Analyzethis {} renableDSCDebugLog DebugThis {} } }
Thanks much