Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Find text in a data stream

Aug
1,915
68
Further to the thread FFIND TPIPE here is a method to search for text in a data stream using PowerShell via PSHELL.
Code:
e:\utils>pshell /s "get-content -path test -stream 'look' | select-string November"

November
Joe
 
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
 
Back
Top