how to check if a specific file extension exists in a folder using powershell?

Question:

I have a root directory that consists of many folders and sub folders. I need to check whether a particular file like *.sln or *.designer.vb exists in the folders or subfolders and output the result in a text file.

For Eg:

the text file will have result somewhat like below:

Any help will be highly appreciated!

Regards,
Ashish

Answer:

Try this:

I turned it into a function with your values as default parameter-values. Call it by using

Or

Output saved to the file ex:

To get the all the filecounts at the start, try:

Source:

how to check if a specific file extension exists in a folder using powershell? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply