Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cruscio opened this issue Oct 23, 2019 · 1 comment

Comments

@cruscio
Copy link

cruscio commented Oct 23, 2019

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?

@EsOsO
Copy link
Collaborator

EsOsO commented Nov 8, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants