2011-08-24 69 views
1

內容test.ps1的:PowerShell中獲取-ItemProperty將返回1個額外的字符註冊表值的

Set-Location HKLM: 
$RegistryKeys = (Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\services\VMSMP\Parameters\NicList) 
foreach ($Key in $RegistryKeys){ 
    if ((Get-ItemProperty $Key).FriendlyName -like "*Corp*") { 
     Write-Host "Found Switch in $Key" 
     $SwitchName = (Get-ItemProperty -Path $Key).SwitchName 
     $PortName = (Get-ItemProperty -Path $Key).PortName 
     Write-Host $SwitchName 
     Write-Host $PortName 
    } 
    else{} 
} 

輸出(我跑了它在快速連續4次作出強調上怪異多餘的字符被添加到返回的值):

Found Switch in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\VMSMP\Parameters\NicList\03BDF338-4BC5-4896-8C40-55C91DEBB50D 
D00D57C1-8FE2-447F-ABBD-B672CA2683CCø 
D5BD78A2-543F-4F15-9FA6-729F62AE09A3ø 
Found Switch in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\VMSMP\Parameters\NicList\03BDF338-4BC5-4896-8C40-55C91DEBB50D 
D00D57C1-8FE2-447F-ABBD-B672CA2683CCø 
D5BD78A2-543F-4F15-9FA6-729F62AE09A3ø 
Found Switch in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\VMSMP\Parameters\NicList\03BDF338-4BC5-4896-8C40-55C91DEBB50D 
D00D57C1-8FE2-447F-ABBD-B672CA2683CCø 
D5BD78A2-543F-4F15-9FA6-729F62AE09A3ø 
Found Switch in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\VMSMP\Parameters\NicList\03BDF338-4BC5-4896-8C40-55C91DEBB50D 
D00D57C1-8FE2-447F-ABBD-B672CA2683CCø 
D5BD78A2-543F-4F15-9FA6-729F62AE09A3ø 
Found Switch in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\VMSMP\Parameters\NicList\03BDF338-4BC5-4896-8C40-55C91DEBB50D 
D00D57C1-8FE2-447F-ABBD-B672CA2683CCm 
D5BD78A2-543F-4F15-9FA6-729F62AE09A3m 

請告訴我有被添加到註冊表項多餘的字符?除了那個額外的垃圾字符外,正在返回的信息是正確的。有時它的o,m,s,?,但似乎總是隻有一個字符(有時它不會添加額外的字符)。

猛然一驚.....

+0

您試圖找回的值的數據類型是什麼? – Aaron

回答

0

我最好的猜測是,你得到的價值是多串鑰匙,和那些奇怪的字符是字符串分隔符。不過,我的計算機上沒有VMSMP密鑰來驗證我的理論。

相關問題