fix stopiffails switch logic. suppress error output

This commit is contained in:
OCram85 2018-03-13 14:44:26 +01:00
parent e50acbcfbe
commit f33a243191
2 changed files with 3 additions and 3 deletions

View File

@ -83,7 +83,7 @@ Could not find the required {0} called {1}. Please install the required {0} to r
}
'PSSnapin' {
if (Get-PSSnapin -Name $Name -Registered) {
if (Get-PSSnapin -Name $Name -Registered -ErrorAction SilentlyContinue) {
return $true
}
else {

View File

@ -43,7 +43,7 @@ Describe "Test-ModuleName" {
Test-Module -Name 'foobar2000' -Type PSSnapin | Should -Be $false
}
It "StopifFails switch should thrown an error" {
{Test-Module -Name 'foobar2000' -Type PSSnapin }| Should -Throw
{Test-Module -Name 'foobar2000' -Type PSSnapin -StopIfFails }| Should -Throw
}
}
Context "Working with modules" {
@ -59,7 +59,7 @@ Describe "Test-ModuleName" {
Test-Module -Name 'foobar2000' -Type Module | Should -Be $false
}
It "StopifFails switch should thrown an error" {
{Test-Module -Name 'foobar2000' -Type Module }| Should -Throw
{Test-Module -Name 'foobar2000' -Type Module -StopIfFails }| Should -Throw
}
}
}