Fix GetComputerInfo test for looking up registry (#3065)

* Fix GetComputerInfo test for looking up registry

* Addressed code review comments
This commit is contained in:
Aditya Patwardhan 2017-02-01 17:49:33 -08:00 committed by Mike Richmond
parent 8303a2b3fb
commit a69116db05

View file

@ -750,7 +750,8 @@ public static extern int LCIDToLocaleName(uint localeID, System.Text.StringBuild
param([string]$propertyName) param([string]$propertyName)
$key = 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\' $key = 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\'
$regValue = (Get-ItemProperty -Path $key -Name $propertyName).$propertyName $regValue = (Get-ItemProperty -Path $key -Name $propertyName -ErrorAction SilentlyContinue).$propertyName
if ($propertyName -eq "InstallDate") if ($propertyName -eq "InstallDate")
{ {
# more complicated case: InstallDate # more complicated case: InstallDate
@ -763,6 +764,8 @@ public static extern int LCIDToLocaleName(uint localeID, System.Text.StringBuild
{ {
return $regValue return $regValue
} }
return $null
} }
function Get-ExpectedComputerInfoValue function Get-ExpectedComputerInfoValue