js2010
November 12, 2020, 10:39am
21
You can have an integer array of id’s in get-winevent with the filterhashtable. There’s some annoying problems with it over invoke-command in all powershell versions. This worked for me at an elevated prompt.
$eventids = 5,7
invoke-command localhost { [int[]]$eventids = $using:eventids;
get-winevent @{logname='system';id=$eventids } }
[quote quote=271120]Are you sure the PS version on the other servers is the same?
A quick check running powershell -version 2.0 confirms that the error is the same. I can’t get it to return anything different.
<textarea class="urvanov-syntax-highlighter-plain print-no" style="tab-size: 4; font-size: 14px !important; line-height: 18px !important; z-index: 0; opacity: 0;" readonly="readonly" data-settings="dblclick">PS E:\temp> powershell -version 2.0
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS E:\temp> ‘1’ -in ‘1’,‘2’,‘3’
: You must provide a value expression on the right-hand side of the ‘-’ operator.
CategoryInfo : ParserError: ( , ParentContainsErrorRecordException
FullyQualifiedErrorId : ExpectedValueExpression</textarea>
PS E : \ temp > powershell -version 2. 0
Windows PowerShell
Copyright ( C ) 2009 Microsoft Corporation . All rights reserved .
PS E : \ temp > '1' -in '1' , '2' , '3'
- : You must provide a value expression on the right -hand side of the '-' operator .
+ CategoryInfo : ParserError : ( : ) [ ] , ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
[/quote]
Hi Matt,
You’re absolutely right - I had wrong info. These 2 servers only are 2008R2, the others are 2012.
That explains it then as I have tested with -match and it works OK.
Sorry to you and Mike for the confusion and thanks for your input and assistance!
J