I'm trying to create a commandlet (tried alias, but I understand it can't do what I need), to essentially do the linux equivalent of: history | grep "string".
This is the function I've created after researching on SO: function hg {h | Select-String -Pattern $pattern}
But when I call it as: hg "some string", I get the error below.
Select-String : Cannot bind argument to parameter 'Pattern' because it is null. At line:1 char:41
- function hg {h | Select-String -Pattern $pattern}
-
~~~~~~~~- CategoryInfo : InvalidData: (:) [Select-String], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SelectStringCommand
Yes, pattern is null, THAT'S WHY i'm passing a value to it.
I'm about to break a monitor, I've spent an hour trying to find a solution through 100 different combinations, this is utterly infuriating.