File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 2525 the user the PowerShell is running with. If this is set and the user the PowerShell is
2626 running with can access to the MSSQL database you will not require to provide username
2727 and password
28+ . PARAMETER TestConnection
29+ Set this if you want to return $null on connection errors during MSSQL.open() instead of
30+ exception messages.
2831. OUTPUTS
2932 System.Data.SqlClient.SqlConnection
3033. LINK
@@ -38,7 +41,8 @@ function Open-IcingaMSSQLConnection()
3841 [string ]$Address = " localhost" ,
3942 [int ]$Port = 1433 ,
4043 [string ]$SqlDatabase ,
41- [switch ]$IntegratedSecurity = $FALSE
44+ [switch ]$IntegratedSecurity = $FALSE ,
45+ [switch ]$TestConnection = $FALSE
4246 );
4347
4448 if ($IntegratedSecurity -eq $FALSE ) {
@@ -80,6 +84,11 @@ function Open-IcingaMSSQLConnection()
8084
8185 $SqlConnection.Open ();
8286 } catch {
87+
88+ if ($TestConnection ) {
89+ return $null ;
90+ }
91+
8392 Exit-IcingaThrowException `
8493 - InputString $_.Exception.Message `
8594 - StringPattern $Username `
You can’t perform that action at this time.
0 commit comments