On Command Prompt I can enumerate all files in a directory tree and run an arbitrary command on all of them with either:
FOR /R %F IN (*) DO @COMMAND-HERE ARGS-HERE
Directories only:
FOR /R /D %D IN (*) DO @COMMAND-HERE ARGS-HERE
What are the equivalent commands on PowerShell?
To iterate over all items in a folder and perform an action against them you can recursively iterate over them and with a pipe you can perform an action against that item
And I believe you can use this for directories.
Hope that helps.