Enabling / Disabling logging

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Ryan Young Ryan Young 2 years ago.

  • Author
    Posts
  • #20899
    Profile photo of Ryan Young
    Ryan Young
    Participant

    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 🙂

  • #20900
    Profile photo of Ryan Young
    Ryan Young
    Participant

    Found my own issue, I had multiple "script" entries with the same name, I blame copy paste haha :). Question is still valid though! What's the best way to do this 🙂

You must be logged in to reply to this topic.