dir mysharec$data** eports* | `
Where { $_.LastWriteTime -lt (Get-Date -Format MM-dd-yyyy) } | `
% { Split-Path $_.fullname } | `
Group | `
Where { $_.Count -gt 1 } | `
select name
This script does a few things:- Looks for folders at a specific depth without having to recurse by using wildcards
- Filters the folders so only folder last written to yesterday (or earlier) are returned
- Gathers the main folder path with Split-Path against the pipelined Directory object
- Groups the objects
- Filters on groups to return collections (2 or more)
- Selects name only
Using this approach I can narrow down my search to exactly what I need to look at without manually touching anything.