-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGet-DecodedMRU.ps1
46 lines (45 loc) · 1.94 KB
/
Get-DecodedMRU.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# https://gist.github.com/jasonadsit/2ed555868a995ba4b429dafb18ecf6e4
function Get-DecodedMRU {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string] $MRU
)
process {
$ErrorActionPreferenceBak = $ErrorActionPreference
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
try {
$items = Get-Item -Path $MRU | Select-Object -ExpandProperty Property
$data = @()
foreach ($item in $items) {
$name = $item
$valuekind = $($(Get-Item $MRU).GetValueKind("$name"))
$bin = (Get-ItemProperty -Path $MRU -Name $name -ErrorAction SilentlyContinue)."$name"
if ($valuekind -eq "BINARY") {
$decoded = @()
$asciirange = 32..126
foreach ($dec in $bin) {
if ($asciirange -like $dec) {
$decoded += [char]$dec
} #if ($asciirange -like $dec)
} #foreach
} #if ($valuekind -eq "BINARY")
$data += New-Object -TypeName psobject -Property @{
Name = [string] "$name"
BinaryValue = [byte[]] $bin
DecodedValue = [string] $($decoded -join "")
Type = [string] $valuekind
}
} #foreach ($item in $items)
} catch {
# Nothing to see here. Move along.
} #trycatch
$ErrorActionPreference = $ErrorActionPreferenceBak
Write-Output -InputObject $data
Clear-Variable -Name name
Clear-Variable -Name bin
Clear-Variable -Name decoded
Clear-Variable -Name valuekind
Clear-Variable -Name data
} #process
} #function Get-DecodedMRU