FriedrichWeinmann / bConnect

PowerShell Module to interact with the Baramundi bConnect Rest API
MIT License
3 stars 1 forks source link

Assert-bConnectConnection dosn't terminate when required Version is false #2

Closed mueller-tobias closed 1 year ago

mueller-tobias commented 6 years ago

Through an typo in Assert-bConnectConnection ($connectVersion vs $_connectVersion) i recognized that the Stop-PSFunction dosnt't terminate the calling script when the version requirements aren't meet.

I realized that throwing an error inside the try/catch would trigger the Catch Block what wasn't supposed, so i moved the If block below the try/catch block

Although even outside the try/catch block Stop-PSFunction dosn't throw an terminating error, but throw does.

Dosn't work: Stop-PSFFunction -Message "bConnect has not the Required Version: $MinVersion" -EnableException $true -Cmdlet $PSCmdlet Works: Throw "bConnect has not the Required Version: $MinVersion"

Stop-PSFFunction seems to be only working when $ErrorActionPreference is "Stop", while Throw is also terminating with the Default Value "Continue"

Assert-bConnectConnection.txt