I have been troubleshooting a issue where sometimes Add-LoggingTarget randomly fails to load custom targets. However, if I add my custom target into the Target folder for the module, I do not have this issue. I used Get-LoggingTargetAvailable to test to see if the target was loaded, and it was. The issue is very intermittent.
powershell.exe : Add-LoggingTarget : Cannot validate argument on parameter 'Name'. The argument
At line:3 char:5
+ & powershell -NonInteractive -executionpolicy bypass -file C:\scr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Add-LoggingTarg.... The argument :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
"Gelf" does not belong to the set "Email,Console,ElasticSearch,File,Slack"
specified by the ValidateSet attribute. Supply an argument that is in the set
and then try the command again.
At C:\scripts\Test-Import\Test-Import.ps1:22 char:29
+ Add-LoggingTarget -Name Gelf -Configuration @{
+ ~~~~
+ CategoryInfo : InvalidData: (:) [Add-LoggingTarget], ParentCont
ainsErrorRecordException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Add-LoggingTarg
et