gci D:\ -r -file -ea 0 | sort LastWriteTime -desc | select -f 50 LastWriteTime,FullName
This command recursively searches the D:\ drive for files, suppresses access errors, sorts the results by last modified date, and displays the 50 most recently modified files.
Breakdown
gci
Alias for Get-ChildItem. Lists files and folders in a location.
D:\
The path to search.
-r
Short form of -Recurse. Searches through all subfolders.
-file
Returns files only, excluding folders.
-ea 0
Short form of -ErrorAction SilentlyContinue. Suppresses non-critical errors, such as access denied messages.
sort LastWriteTime -desc
Sorts the results by the LastWriteTime property in descending order, so the newest files appear first.
select -f 50 LastWriteTime,FullName
Displays only the first 50 results, showing the file’s last modified date and full path.