Split Select-String
13,807
The string value of the matched line is in the Line property of the MatchInfo object.
$foo.Line.split()
Comments
-
Zombo almost 2 years
Given this variable
$foo = help | Select-String powershell
Trying a split will fail
PS > $foo.split() Method invocation failed because [Microsoft.PowerShell.Commands.MatchInfo] does not contain a method named 'split'. At line:1 char:1 + $foo.split() + ~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
How can I split this variable?
-
Keith Hill almost 10 yearsWhile this works, it is not exactly embracing the nature of PowerShell i.e. it outputs objects not merely text. :-)