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 - get-child item question from a newbie

Reply
 
Old 08-29-2007   #11 (permalink)
powersheller


 
 

Re: get-child item question from a newbie

On Aug 29, 11:00 am, "Keith Hill [MVP]"
<r_keith_h...@xxxxxx_no_spam_I> wrote:
Quote:

> <powershel...@xxxxxx> wrote in message
>
> news:1188399013.650799.260310@xxxxxx
>
Quote:

> > First of all, I want to thank everyone that has offered suggestions.
> > I'm still a bit stumped on this.
> > as far as I can tell the solutions don't address the fact that I just
> > want to step one level deep from the current dir and run a specific
> > command (in this case it's actually a script that must be run from
> > current dir, I can't just run it from a different dir with the correct
> > path.) and then I need to go back up one dir and then back down into
> > the next dir and run the same command.
> > I don't think I need -recurse because I don't want to go deeper than
> > the one level.
>
> Missed that part - sorry. Then this should work for you:
>
> get-item * | where {$_.PSIsContainer} | set-location -passthru | foreach {
> c:\myscript.ps1}
>
> get-item * will get the items (files/folders) in the current directory and
> pass them to the where filter which filters out the files.
>
> --
> Keith
Thanks Keith, and everyone else that commented. This is an example of
what I ended up getting to work

get-ChildItem * | where {$_.PSIsContainer} | set-Location -passthru |
foreach {sub\junk}

so for each subdir I am running another command which is always
located in a dir called sub

full structure
c:\test\sample\sub\<junk.exe>
c:\test\sample1\sub\<junk.exe>
c:\test\sample2\sub\<junk.exe>
c:\test\sample3\sub\<junk.exe>
I run the command above from \test and it runs each instance of
junk.exe from within \sample* dir

THANKS!


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
how to show the name of child item after its in the pipeline? PowerShell
Re: Newbie Question Live Mail
Newbie Question #3 General Discussion
RE: Newbie Question 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