# Enabling / Disabling logging

**URL:** <https://forums.powershell.org/t/enabling-disabling-logging/3471>\
**Category:** DSC\
**Created:** [December 2, 2014, 8:05am UTC](https://forums.powershell.org/t/enabling-disabling-logging/3471 "2014-12-02T08:05:17Z")\
**Posts on this page:** 3\
**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 2, 2014, 8:05am UTC](https://forums.powershell.org/t/enabling-disabling-logging/3471/1 "2014-12-02T08:05:17Z")

</div>

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 🙂

---

<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 2, 2014, 8:15am UTC](https://forums.powershell.org/t/enabling-disabling-logging/3471/2 "2014-12-02T08:15:48Z")

</div>

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 🙂

---

<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/enabling-disabling-logging/3471/3 "2024-05-16T21:17:27Z")

</div>

Closed on May 16, 2024, 9:17pm UTC


