From a69116db05a9776964137a7a8cd29e3a5ddc8de3 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 1 Feb 2017 17:49:33 -0800 Subject: [PATCH] Fix GetComputerInfo test for looking up registry (#3065) * Fix GetComputerInfo test for looking up registry * Addressed code review comments --- .../Get-ComputerInfo.Tests.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 index 0830cc61f..bf69477a3 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 @@ -750,7 +750,8 @@ public static extern int LCIDToLocaleName(uint localeID, System.Text.StringBuild param([string]$propertyName) $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") { # more complicated case: InstallDate @@ -763,6 +764,8 @@ public static extern int LCIDToLocaleName(uint localeID, System.Text.StringBuild { return $regValue } + + return $null } function Get-ExpectedComputerInfoValue