View Single Post
Old 08-29-2007   #4 (permalink)
Brandon Shell


 
 

Re: get-child item question from a newbie

I read your question as you just want to run some specific EXE's in
subfolders... if that is this case. These will help.

If your intent is to run a specific list of exe's in each subfolder you and
do this.
$include = "somecommand.exe","somecommand2.exe"
get-childitems c:\somedir -include $include -recursive | %{invoke-express
$_.fullname}

Info: Get-Childitem has an include parameter that allows you match a string
or an array of string. In this case an array of strings that contains
filename of the EXE(s)

If you just want to run all of them
get-childitems c:\somedir -filter *.exe -recursive | %{invoke-express
$_.fullname}

Info: Get-Childitem has a Filte parameter that lets you filter the result
set by a specific string. In this case *.exe

NOTE: You dont have to be in the folder of the EXE to execute. It is just
like cmd prompt in that aspect. As long as you qualify the path you are
good.

For more info
PS> get-help Get-Childitem -full

<powersheller@xxxxxx> wrote in message
news:1188345673.374024.311640@xxxxxx
Quote:

> Ok, this is my first day working with powershell. I'm sure this
> question couldn't be easier, but I can't seem to figure it out.
>
> All I want to do is run a script which would accomplish the following.
>
> run a command in each sub directory
>
> here is what I would do at a command line.
> c:\somedir> cd\subdir
> c:\somedir\subdir>
> c:\somedir\subdir>somecommand.exe
> c:\somedir\subdir>cd..
> c:\somedir\>cd\subdir2
> c:\somedir\subdir2>somecommand.exe
>
> etc. it's probably very easy, but I can't figure out how to pass the
> get-child item result to set-location
>
>
> any suggestions would be greatly appreciated.
>
> ej
>
My System SpecsSystem Spec