hello
i am trying to grap all folders with “paris” in the name string in the c:\RootFolder, the problem is that sometimes it retrive all folders sometimes only one occurence…i do not know why.
When the name starts with Paris, you’re overwriting the value of $list with a new array. When it doesn’t start with Paris, you’re adding to the variable.
Personally, I don’t like this approach anyway. Use the Pipeline, and let PowerShell convert it to an array for you if there are multiple results. The performance will be better. For example: