Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - how to show the name of child item after its in the pipeline?

Reply
 
Old 01-05-2009   #1 (permalink)
drew


 
 

how to show the name of child item after its in the pipeline?

hi list;
i am using the following to search status reports and extract hours estimates
get-childitem |get-content |where-object{$_ -match "hours"}

works great because it saves a ton of work, but what i'd really like is to
be able to take the name of the chiditem piped and expose its name at the
start of the line, so it should look like

filename1 estimated hours 40-60
filename2 estimated hours 35-50
filenameN estimated hours ddd-ddd

but sticking anything between get-childitem and get-content ain't gettin it.
thanks very much for your help


My System SpecsSystem Spec
Old 01-05-2009   #2 (permalink)
Kiron


 
 

Re: how to show the name of child item after its in the pipeline?

Select-String returns Microsoft.PowerShell.Commands.MatchInfo object -unless the -List switch is present.
Its output by default shows the Microsoft.PowerShell.Commands.MatchInfo's Filename, LineNumber and Line properties:

# pipe the items to its Path parameter by Property Name
# and a RegEx to its Pattern parameter positionally
ls | select-string hours

# if you don't want the line number
ls | select-string hours | % {$_.filename + ':' + $_.line}

This Cmdlet performs great...

--
Kiron
My System SpecsSystem Spec
Old 01-05-2009   #3 (permalink)
Kiron


 
 

Re: how to show the name of child item after its in the pipeline?

# oops
-unless the -List switch is present.

# should be...
-unless the -Quiet switch is present.

--
Kiron
My System SpecsSystem Spec
Old 01-06-2009   #4 (permalink)
drew


 
 

Re: how to show the name of child item after its in the pipeline?

this powershell stuff makes me feel kinda dizzy and my mouth get dry...
thanks a ton Kiron.
drew

"Kiron" wrote:
Quote:

> # oops
> -unless the -List switch is present.
>
> # should be...
> -unless the -Quiet switch is present.
>
> --
> Kiron
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Copy-Item : Container cannot be copied onto existing leaf item. PowerShell
How to iterate through child items in pipeline PowerShell
Pipeline input problems using Get-ChildItem and Invoke-Item PowerShell
Menu Item Icon shows in the IDE but does not show when app is runn .NET General
get-child item question from a newbie PowerShell


Vista Forums 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 Ltd

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