This topic contains 2 replies, has 2 voices, and was last updated by
August 12, 2015 at 8:37 am #28494ParticipantTopics: 5Replies: 8Points: 0Rank: Member
I have a strange issue here:
$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?
August 12, 2015 at 8:42 am #28495KeymasterTopics: 13Replies: 4872Points: 1,811Rank: Community Hero
Your second example is using an array of strings:
Your not-working is using a single string:
The quotes prevent PowerShell from recognizing it as an array. Instead:
Notice that the commas aren't in quotes.
August 12, 2015 at 8:48 am #28498ParticipantTopics: 5Replies: 8Points: 0Rank: Member
Thanks, I was already thinking in that direction, but did not get the syntax right it seems.
The topic ‘Get-EventLog and variables’ is closed to new replies.