powershell, write-host all filenames of the files


I am now better in writing, stealing and modifying scripts but here I am a stuck a little.
My script sums up files in a specific folder and counts them.
Like this :

What’s the smartest way to list all files from that folder using write-host? I tried to put a write-host $colitems.Fullname without good results.

I know that I could easily put the files in a loop and than use foreach and display the filename. But for that I have to change everything. So is there a way?

Right now it displays something like that :

What I need before that output is a list of all files with path

Any Ideas or tips ?


You could capture the list of files in the first pipeline using tee-object, and then use foreach on that.


powershell, write-host all filenames of the files by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply