This post says to apply a script to all subdirectories use the following command.
Get-ChildItem -Recurse | ForEach-Object { & "C:PathToYourScript.ps1" $_.FullName }
The issue is this command runs in a loop. Minor issue for me, because my command generates a file. When the first loop is finished, it will ask if I want to rewrite. Is there a way to run this once, not endlessly?
The post has another command.
Get-ChildItem -Recurse -Directory | ForEach-Object { Write-Output "Executing script in $($_.FullName)" # Add your commands or script functionality here }
which I haven’t tried.