File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ function Get-IcingaMSSQLInstanceName ()
2+ {
3+ param (
4+ $SqlConnection = $null ,
5+ [string ]$Username ,
6+ [securestring ]$Password ,
7+ [string ]$Address = " localhost" ,
8+ [int ]$Port = 1433 ,
9+ [switch ]$IntegratedSecurity = $FALSE ,
10+ [switch ]$TestConnection = $FALSE
11+ );
12+
13+ [bool ]$NewSqlConnection = $FALSE ;
14+
15+ if ($null -eq $SqlConnection ) {
16+ $SqlConnection = Open-IcingaMSSQLConnection - Username $Username - Password $Password - Address $Address - IntegratedSecurity:$IntegratedSecurity - Port $Port - TestConnection:$TestConnection ;
17+
18+ if ($null -eq $SqlConnection ) {
19+ return ' Unknown' ;
20+ }
21+
22+ $NewSqlConnection = $TRUE ;
23+ }
24+
25+ $Query = ' SELECT @@servicename'
26+ $SqlCommand = New-IcingaMSSQLCommand - SqlConnection $SqlConnection - SqlQuery $Query ;
27+ $InstanceName = (Send-IcingaMSSQLCommand - SqlCommand $SqlCommand ).Column1;
28+
29+ if ($NewSqlConnection -eq $TRUE ) {
30+ Close-IcingaMSSQLConnection - SqlConnection $SqlConnection ;
31+ }
32+
33+ return $InstanceName ;
34+ }
You can’t perform that action at this time.
0 commit comments