I have a simple query that lists all folders recursively that do not contain any files within them. I also need to filter it so that it only lists folders that also do not have any sub-folders. The following script will return only folders without files within them, but how would i also add it so that it lists folders without any sub-folders? Thanks.
(Get-ChildItem C:\Temp -recurse | Where-Object {$_.PSIsContainer -eq $True}) ` | Where-Object {$_.GetFiles().Count -eq 0} | Select-Object FullName,Parent,Name,CreationTime,LastWriteTime