Find text in a data stream

May 26, 2008
513
4
Powershell is amazing. The fact that it transmits objects through the pipeline is extremely powerful. (It does not send basic text like cmd, bash, tcc, etc....)
 
Well, for those new to Powershell, please remember that PowerShell returns objects, not strings.
Code:
e:\utils>pshell /s "(get-content -path test -stream 'look' | select-string November).GetType()"

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    MatchInfo                                System.Object
Note that in post #1 of this thread, there is a blank line and then "November". That's because PowerShell returned an object.

To eliminate the blank line, cast the return type of the Object as a string;
Code:
e:\utils>pshell /s "(get-content -path test -stream 'look' | select-string November).ToString()"
November
Proof;
Code:
e:\utils>pshell /s "((get-content -path test -stream 'look' | select-string November).ToString()).GetType()"

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object
Joe