diff --git a/src/Helper/Test-Module.ps1 b/src/Helper/Test-Module.ps1 index 70afa70..f116459 100644 --- a/src/Helper/Test-Module.ps1 +++ b/src/Helper/Test-Module.ps1 @@ -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 { diff --git a/tests/Helper/01_Test-Module.Tests.ps1 b/tests/Helper/01_Test-Module.Tests.ps1 index 3513521..675a2dc 100644 --- a/tests/Helper/01_Test-Module.Tests.ps1 +++ b/tests/Helper/01_Test-Module.Tests.ps1 @@ -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 } } }