I am using Weird-Cmd that has been written by someone else. This command searches the database for things and accepts certain parameters for its -Filter.
If I pass a bogus filter parameter, it returns a message telling me there's no such filter parameter.
That message is reported on Information stream (6). How do I invoke this cmdlet inside a try/catch and catch this error that is being reported on Information stream.
I tried redirecting the stream but it turned out PowerShell doesn't redirect except to Output/Success.
I do not have access to Weird-Cmd so I can't change it. I am limited to PowerShell 5.1.
Here is the message I get:
System.Management.Automation.ParentContainsErrorRecordException: Cannot bind parameter 'Filter' to the target. Exception setting "Filter": ""BogusProp" is not a recognized filterable property. Valid property names are: Prop1, Prop2,...."