Review Explorer Recent Items
Code Properties
- Language: PowerShell
- COM Objects:
WScript.Shell
Overview
PowerShell script that reads Windows Explorer recent items (shortcuts) and displays the target files with their last access timestamps.
Code
# create Shell object
$sh = New-Object -ComObject WScript.Shell
# specify path
$RecentItemsPath = "$Env:APPDATA\Microsoft\Windows\Recent"
# get recent items
$RecentItems = Get-ChildItem -Path $RecentItemsPath -Filter "*.lnk" |
Sort-Object LastAccessTime
# loop and output
$RecentItems | ForEach-Object {
$lnk = $sh.CreateShortcut($_.FullName)
$tgt = $lnk.TargetPath
if ($tgt) {
if (Test-Path -Path $tgt -PathType Leaf) {
Write-Host "$($_.LastAccessTime.ToString('yyyy-MM-dd HH:mm:ss')) $($lnk.TargetPath)"
}
}
}Usage
# run script to see recent files
.\Get-RecentItems.ps1
# export to file
.\Get-RecentItems.ps1 | Out-File -FilePath "RecentItems.txt"Appendix
Note created on 2024-09-18 and last modified on 2024-12-31.
See Also
Backlinks
(c) No Clocks, LLC | 2024