A co-worker found this helpful site:
Topic: Return date of most recently modified file in each sub-dir | PowerShell.org[
^]
He wrote the following solution. It doesn't exclude folders, but does traverse folders and copy out the most current file:
# Identify the folder you want to search
$projectsFolder = 'C:\Users\swidene\Documents\DELETE\ACE Enhancement'
# Get the subfolders of the folder being searched and find the most recently modified file
# Sort those files by last modification date in descending order
#copy them to new folder and select the Name, LastWriteTime, and FullName properties and write them to the csv #file
Get-ChildItem -LiteralPath $projectsFolder -Directory -Force | ForEach-Object {
# Get all files under each subfolder, sorted by the last modification date in descending order, select the first one (the most recently modified file) and return it
Get-ChildItem -LiteralPath $_.FullName -File -Recurse -Force | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 1
} | Sort-Object -Property LastWriteTime -Descending |
copy-item -Destination ("C:\Users\swidene\Documents\DELETE\Backup")