Logging icon indicating copy to clipboard operation
Logging copied to clipboard

Add-LoggingTarget : Cannot validate argument on parameter 'Name' for "WinEventLog"

Open cruscio opened this issue 6 years ago • 1 comments

This is happening intermittently in a script that runs as a scheduled task. Sometimes the task starts up and logs fine. Sometimes it throws this error. (PSVersion 5.1.14393.2430, Logging version 4.2.11)

Code that errors

Import-Module Logging
Add-LoggingTarget -Name WinEventLog -Configuration @{
  LogName="$($evt.log)"
  Source ="$($evt.source)"
}

Error message

Add-LoggingTarget : Cannot validate argument on parameter 'Name'. The argument "WinEventLog" does not belong to the 
    set "Email,ElasticSearch,Console,Slack,File,Seq" specified by the ValidateSet attribute. Supply an argument that is in 
    the set and then try the command again.

I'd guess AV or over-provisioned hosting or something else is causing Start-LoggingManager to take longer than 500ms to do its work

From Logging.psm1

Start-LoggingManager

# Let the runspace spinup and generate all the available targets
Start-Sleep -Milliseconds 500 

What would it take to change this from a fixed interval to a loop that checks status every 100ms and either returns when ready or times out with an error?

cruscio avatar Oct 23 '19 23:10 cruscio

Sorry to be late commenting, I'm currently low on time. I'll try to look into this asap, meanwhile feel free to pull a patch

EsOsO avatar Nov 08 '19 08:11 EsOsO