File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 333333 ' Get-DbaMsdtc' ,
334334 ' Get-DbaNetworkActivity' ,
335335 ' Get-DbaNetworkCertificate' ,
336+ ' Get-DbaNetworkEncryption' ,
336337 ' Get-DbaNetworkConfiguration' ,
337338 ' Get-DbaOpenTransaction' ,
338339 ' Get-DbaOperatingSystem' ,
Original file line number Diff line number Diff line change @@ -1068,6 +1068,7 @@ if ($PSVersionTable.PSVersion.Major -lt 5) {
10681068 ' Test-DbaComputerCertificateExpiration' ,
10691069 ' Test-DbaNetworkCertificate' ,
10701070 ' Get-DbaNetworkCertificate' ,
1071+ ' Get-DbaNetworkEncryption' ,
10711072 ' Set-DbaNetworkCertificate' ,
10721073 ' Remove-DbaDbLogShipping' ,
10731074 ' Invoke-DbaDbLogShipping' ,
Original file line number Diff line number Diff line change @@ -92,15 +92,48 @@ function Get-DbaNetworkEncryption {
9292
9393 process {
9494 foreach ($instance in $SqlInstance ) {
95-
9695 try {
96+ $computerName = $instance.ComputerName
97+ $instanceName = $instance.InstanceName
98+ $tlsInstanceName = if ($instanceName -eq " MSSQLSERVER" ) { " " } else { $instanceName }
99+
100+ $resolvedPort = if ($instance.Port -gt 0 ) {
101+ $instance.Port
102+ } elseif ($instanceName -eq " MSSQLSERVER" ) {
103+ 1433
104+ } else {
105+ $null
106+ }
107+
108+ $sqlInstanceName = if ($instanceName -and $instanceName -ne " MSSQLSERVER" ) {
109+ " $computerName \$instanceName "
110+ } else {
111+ $computerName
112+ }
113+
114+ $splatTls = @ {
115+ ComputerName = $computerName
116+ InstanceName = $tlsInstanceName
117+ }
118+
119+ if ($instance.Port -gt 0 ) {
120+ $splatTls.ConnectionType = " TCP"
121+ $splatTls.Port = $instance.Port
122+ }
123+
124+ $cert = Get-SqlServerTlsCertificate @splatTls
125+
126+ if (-not $cert ) {
127+ continue
128+ }
97129
130+ $dnsNames = $cert.DnsNameList
98131
99132 [PSCustomObject ]@ {
100133 ComputerName = $computerName
101134 InstanceName = $instanceName
102135 SqlInstance = $sqlInstanceName
103- Port = $port
136+ Port = $resolvedPort
104137 Subject = $cert.Subject
105138 Issuer = $cert.Issuer
106139 Thumbprint = $cert.Thumbprint
@@ -115,4 +148,4 @@ function Get-DbaNetworkEncryption {
115148 }
116149 }
117150 }
118- }
151+ }
You can’t perform that action at this time.
0 commit comments