Contents of test.ps1:
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{}
}
Output (I ran it 4 times in quick succession to make an emphasis on the weird extra character being added to the returned values):
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
Whats with the extra characters being added to the registry entries? The information being returned is correct except for that extra garbage character. Sometimes its o,m,s,?, but always seems to be one character only (sometimes it doesnt add extra characters).
Boggled.....
My best guess is that you're getting the value to a multi-string key, and those funny characters are the string separators. I don't have the VMSMP
key on my computer to verify my theory, though.
精彩评论