How do I get filename and line count per file using powershell

Question:

I have the following powershell script to count lines per file in a given directory:

This is giving me the following output:

The counts-per-file is fine (I don’t require words, characters, or property), but I don’t know what filename the count is for.

The ideal output would be something like:

How do I add the filename to the output?

Answer:

try this:

Source:

How do I get filename and line count per file using powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply