Last active
January 21, 2024 15:09
-
-
Save rvrsh3ll/1a43f77a25cdda128694148c2e81fc3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-RecentDocs { | |
<# | |
.SYNOPSIS | |
Pulls names of recently opened documents from registry | |
Author: Matthew Graeber (@mattifestation) | |
License: BSD 3-Clause | |
Required Dependencies: None | |
Optional Dependencies: None | |
.DESCRIPTION | |
Reads registry for recently opened document names. | |
.PARAMETER Extension | |
The extension to filter for. Leaving blank will list all. | |
.EXAMPLE | |
Get-RecentDocs -Extension .docx | |
#> | |
Param | |
( | |
[Parameter(Position = 0)] | |
[String] | |
$Extension = '' | |
) | |
$AsciiRegex = [Regex] '[\x20-\x7E]{5,}' | |
$UnicodeRegex = [Regex] '[\u0020-\u007E]{5,}' | |
Get-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.$Extension | % { | |
$Key = $_ | |
$Key.GetValueNames() | % { | |
$AsciiString = [Text.Encoding]::GetEncoding(28591).GetString($Key.GetValue($_)) | |
$UnicodeString = [Text.Encoding]::Unicode.GetString($Key.GetValue($_)) | |
New-Object PSObject -Property @{ | |
ValueName = $_ | |
FileName = $UnicodeRegex.Match($UnicodeString).Value | |
LinkName = $AsciiRegex.Match($AsciiString).Value | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment