View Single Post
Old 08-28-2007   #2 (permalink)
Marco Shaw


 
 

Re: get-child item question from a newbie

powersheller@xxxxxx wrote:
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
>
Welcome!

get-item
*|foreach-object{if($_.psiscontainer){$_}}|foreach-object{set-location
$_;$pwd}

Here "$pwd" is my command I'm running in the current dir. Replace with
your own...

Marco


--
----------------
PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec