Recently we need to search a load of servers locally for files that existed ( lingered ) on peoples local user proflile
Get-ChildItem -Recurse -Force \\servername\c$\Users\*\AppData\Local\Temp | Where-Object {$_.Name -like "Z@*.tmp"} | Export-CSV C:\TempFiles.csv -Append
We then needed to search roaming directories mapped on a file server , I tried to use the above for this command replacing the directory location with a roaming file server location replace * with Users again, however I was getting “Get-ChildItem : Access is denied” with UnauthorizedAccessException , probably because query is too generic! To limit this down, I used the following pipe to query the list of users and then check each folder after