2013-07-01 56 views
4

我有一個MRU列表的以下輸出。我怎樣才能將它轉換爲字符串或ASCII字符?Powershell - 從註冊表項轉換十六進制

'GP 「HKCU:\軟件\微軟\的Windows \ CurrentVersion \ Explorer中\ COMDLG32 \ LastVisitedPidlMRU」'

18:{80,0,120,0 ...}
5:{50, 0,109,0 ...}

+0

你爲什麼讀這個註冊表值?您試圖獲得哪些MRU數據?可能比使用註冊表更好。它看起來像那些值包含二進制數據以及文本。 –

回答

4

假設gp "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedPidlMRU"

給出:

PSPath  : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedPidlMRU 
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32 
PSChildName : LastVisitedPidlMRU 
PSDrive  : HKCU 
PSProvider : Microsoft.PowerShell.Core\Registry 
MRUListEx : {14, 0, 0, 0...} 
11   : {114, 0, 117, 0...} 
9   : {69, 0, 120, 0...} 
19   : {83, 0, 107, 0...} 
10   : {78, 0, 79, 0...} 
17   : {123, 0, 57, 0...} 
15   : {115, 0, 108, 0...} 
7   : {123, 0, 57, 0...} 
4   : {118, 0, 109, 0...} 
21   : {109, 0, 115, 0...} 
22   : {100, 0, 101, 0...} 
24   : {123, 0, 55, 0...} 
8   : {123, 0, 69, 0...} 
0   : {123, 0, 69, 0...} 
5   : {123, 0, 66, 0...} 
12   : {83, 0, 110, 0...} 
20   : {123, 0, 55, 0...} 
23   : {83, 0, 99, 0...} 
2   : {65, 0, 99, 0...} 
16   : {110, 0, 111, 0...} 
1   : {105, 0, 101, 0...} 
18   : {75, 0, 105, 0...} 
6   : {99, 0, 104, 0...} 
13   : {123, 0, 55, 0...} 
3   : {123, 0, 54, 0...} 
14   : {123, 0, 57, 0...} 

你可以試試:

[System.Text.Encoding]::Unicode.GetString((gp "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedPidlMRU")."11") 

這不太好,但它可以幫助

1

使用從this tip您好,腳本專家!博客,你可以做這樣的事情:

$key = "HKCU:\Softw...dlMRU" 
Get-Item $key | select -Expand property | % { 
    $value = (Get-ItemProperty -Path $key -Name $_).$_ 
    [System.Text.Encoding]::Default.GetString($value) 
} 

注意,值可能包含非打印字符,這樣單獨是不夠的。您必須進行一些額外的清理,例如通過在GetString()呼叫上附加-replace '[\x01-\x1F]'

+0

'$ path'是什麼? –

+0

疏忽。固定。 –

3

您可以使用Carbon PowerShell模塊中的Get-RegistryKeyValue。它會返回這個鍵值作爲一個數組,然後您可以解碼:

$path = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedPidlMRU' 
$result = Get-RegistryKeyValue -Path $path -Name 0 
[System.Text.Encoding]::Unicode.GetString($result) 

但它看起來像該註冊表值包含的不僅僅是文本。

免責聲明:我是Carbon模塊的創建者/維護者。