From d9d97a43ca42b3102d16d5a8d743662bd0ab11d2 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Fri, 2 Dec 2016 11:16:11 -0800 Subject: [PATCH] Add ErrorAction Stop so DeviceGuard function (#2825) A non-terminating error is thrown when the namespace does not exist by Get-CimInstance. The namespace is not present on OS versions below Windows 10. It is not caught in the try-catch unless ErrorAction Stop is added. --- .../Get-ComputerInfo.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 50df9aa24b..6500fa569f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 @@ -340,7 +340,7 @@ public static extern int LCIDToLocaleName(uint localeID, System.Text.StringBuild $returnValue = $null try { - $returnValue = Get-CimClassPropVal Win32_DeviceGuard $propertyName -namespace 'root\Microsoft\Windows\DeviceGuard' + $returnValue = Get-CimClassPropVal Win32_DeviceGuard $propertyName -namespace 'root\Microsoft\Windows\DeviceGuard' -ErrorAction Stop } catch { @@ -1187,7 +1187,7 @@ try { Describe "Tests for Get-ComputerInfo: Ensure Type returned" -tags "CI", "RequireAdminOnWindows" { - It "Verfiy type returned by Get-ComputerInfo" { + It "Verify type returned by Get-ComputerInfo" { $computerInfo = Get-ComputerInfo $computerInfo.GetType().Name | Should Be "ComputerInfo" }