I’m pretty unsure how your code snippets belong together / interact with each other. You do not show us the relevant code. Where do you define $root_folder?
OK. But if I understand your code correctly the foreach loop is unnecessary. The function Get-Folder only provides a sinlge folder. So you’re iterating over 1 element.
I cannot reproduce your issue. You may remove all the current code you have at the moment in your loop and replace it with some test code. For example:
That’s nearly impossible. You may restart your Powershell session with the option -noProfile. If that does not help try the code on another machine please.