Powershell – Exclude folders in Get-ChildItem

Question:

How to exclude folders ? Now I hardcode the folder names but i want it to be more flexible.

Answer:

“How to exclude folders ?” , if you mean all folders :

but it works only for the first level of $fileDirectory .
This works recursevly :

or

Source:

Powershell – Exclude folders in Get-ChildItem by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply