I have a strange issue here:
This works:
$entrytype = "Error" Get-EventLog -LogName System -EntryType $entrytype}
This also works:
Get-EventLog -LogName System -EntryType "Error,Information,Warning,SuccessAudit,FailureAudit"}
However, this doesn’t work:
$entrytype = "Error,Information,Warning,SuccessAudit,FailureAudit" Get-EventLog -LogName System -EntryType $entrytype}
The error returned is:
Cannot validate argument on parameter 'EntryType'. The argument "Error,Information,Warning,SuccessAudit,FailureAudit" does not belong to the set "Error,Information,FailureAudit,SuccessAudit,Warning" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again. + CategoryInfo : InvalidData: (:) [Get-EventLog], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetEventLogCommand
If you look at the error, I am providing exactly what it wants but still it doesn’t like it for some reason, and I cannot figure out why.
So in short, if I put more than 1 EntryType in a variable, it’s not accepted anymore.
Why o why?