Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Has select-string changed behavior with RC2?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 10-18-2006   #1 (permalink)
forestial
Guest


 

Has select-string changed behavior with RC2?

I have previously (some months ago, earlier PS build) used a command such as

get-content *.ps1 | select-string function -list | % { $_.path }

(trying to list all the files in current directory that have functions
defined in them).

This used to give me the filenames. Now all I get is output like this

InputStream
InputStream
InputStream
InputStream
InputStream

..... (one line for each file that select-string finds with a match)

select-string produces a stream of MatchInfo objects; but why does the path
field of the MatchInfo object not identify the filename? MatchInfo also has
a filename property; it behaves the same.

I see that I can achieve my goal directly with select-string thus:
select-string -path *.ps1 -list | % { $_.path }

which is fine for this simple case - but what if I need something more
complex earlier in the stream to identify the set of files to be searched?
For example, I want to find all such files in a directory tree and search
them:

get-childitem -path *.ps1 -recurse | get-content | select-string function
-list | % { $_.path }

My System SpecsSystem Spec
Old 10-18-2006   #2 (permalink)
Lee Holmes [MSFT]
Guest


 

Re: Has select-string changed behavior with RC2?

I think you probably used "Get-Item" to start the pipeline.

Lee

"forestial" <forestial@discussions.microsoft.com> wrote in message
news3842C0C-0810-4065-8525-7411B44E0AE8@microsoft.com...
>I have previously (some months ago, earlier PS build) used a command such
>as
>
> get-content *.ps1 | select-string function -list | % { $_.path }
>
> (trying to list all the files in current directory that have functions
> defined in them).
>
> This used to give me the filenames. Now all I get is output like this
>
> InputStream
> InputStream
> InputStream
> InputStream
> InputStream
>
> .... (one line for each file that select-string finds with a match)
>
> select-string produces a stream of MatchInfo objects; but why does the
> path
> field of the MatchInfo object not identify the filename? MatchInfo also
> has
> a filename property; it behaves the same.
>
> I see that I can achieve my goal directly with select-string thus:
> select-string -path *.ps1 -list | % { $_.path }
>
> which is fine for this simple case - but what if I need something more
> complex earlier in the stream to identify the set of files to be searched?
> For example, I want to find all such files in a directory tree and search
> them:
>
> get-childitem -path *.ps1 -recurse | get-content | select-string function
> -list | % { $_.path }



My System SpecsSystem Spec
Old 10-18-2006   #3 (permalink)
forestial
Guest


 

Re: Has select-string changed behavior with RC2?

Ouch! You are correct. My memory is bad, and my notes are worse.

"Lee Holmes [MSFT]" wrote:

> I think you probably used "Get-Item" to start the pipeline.
>
> Lee
>
>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Select-String -exclude Paul Farrimond PowerShell 7 08-18-2008 10:35 AM
Strange behavior regarding here-string and backtick GS PowerShell 9 07-29-2008 02:00 AM
problems with $var | select-string -pattern $string -q Ben Christian PowerShell 3 02-08-2008 12:41 PM
select-string and .split alicain PowerShell 3 10-12-2007 11:01 AM
Re: select-string exceptions cmyers PowerShell 2 05-23-2007 06:06 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51