@@ -85,6 +85,7 @@ function Set-DbaNetworkCertificate {
8585 - ComputerName: The name of the computer where the SQL Server instance is hosted
8686 - InstanceName: The SQL Server instance name (e.g., MSSQLSERVER, SQL2008R2SP2)
8787 - SqlInstance: The full SQL Server instance name (computer\instance)
88+ - ServiceAccount: The service account running the SQL Server instance
8889 - CertificateThumbprint: The SHA-1 thumbprint of the newly configured certificate in lowercase
8990 - Notes: Summary of actions performed, including whether an old certificate was replaced
9091
@@ -204,8 +205,9 @@ function Set-DbaNetworkCertificate {
204205 }
205206
206207 [PSCustomObject ]@ {
207- Verbose = $verbose
208- Exception = $exception
208+ Verbose = $verbose
209+ Exception = $exception
210+ ServiceAccount = $wmiService.ServiceAccount
209211 }
210212 }
211213 }
@@ -230,6 +232,9 @@ function Set-DbaNetworkCertificate {
230232 }
231233
232234 foreach ($instance in $SqlInstance ) {
235+ $newThumbprint = $null
236+ $stepCounter = 0
237+ Write-ProgressHelper - StepNumber ($stepCounter ++ ) - Message " Testing certificate configuration for $instance "
233238 Write-Message - Level Verbose - Message " Processing $instance " - Target $instance
234239 # Using Test-DbaNetworkCertificate without certificate will use Get-DbaNetworkConfiguration to get all the information we need.
235240 # The commands also tests for elevation requirements and connectivity so we don't have to here.
@@ -252,6 +257,7 @@ function Set-DbaNetworkCertificate {
252257 ComputerName = $certTest.ComputerName
253258 InstanceName = $certTest.InstanceName
254259 SqlInstance = $certTest.SqlInstance
260+ ServiceAccount = $null
255261 CertificateThumbprint = $null
256262 Notes = ' No changes needed'
257263 }
@@ -267,6 +273,7 @@ function Set-DbaNetworkCertificate {
267273 ComputerName = $certTest.ComputerName
268274 InstanceName = $certTest.InstanceName
269275 SqlInstance = $certTest.SqlInstance
276+ ServiceAccount = $null
270277 CertificateThumbprint = $oldThumbprint
271278 Notes = ' No changes needed'
272279 }
@@ -306,6 +313,7 @@ function Set-DbaNetworkCertificate {
306313 ComputerName = $certTest.ComputerName
307314 InstanceName = $certTest.InstanceName
308315 SqlInstance = $certTest.SqlInstance
316+ ServiceAccount = $null
309317 CertificateThumbprint = $oldThumbprint
310318 Notes = ' No changes needed'
311319 }
@@ -326,6 +334,7 @@ function Set-DbaNetworkCertificate {
326334 $message = " Configuring certificate $newThumbprint "
327335 }
328336 if ($PScmdlet.ShouldProcess ($instance , $message )) {
337+ Write-ProgressHelper - StepNumber ($stepCounter ++ ) - Message " $message for $instance "
329338 $result = Invoke-Command2 - ScriptBlock $scriptBlock - ArgumentList $instance , $newThumbprint - ComputerName $ ($certTest.ComputerName ) - Credential $Credential - ErrorAction Stop
330339 foreach ($verbose in $result.Verbose ) {
331340 Write-Message - Level Verbose - Message $verbose
@@ -343,6 +352,7 @@ function Set-DbaNetworkCertificate {
343352
344353 $notes = $null
345354 if ($RestartService ) {
355+ Write-ProgressHelper - StepNumber ($stepCounter ++ ) - Message " Restarting SQL Server service for $instance "
346356 try {
347357 $null = Restart-DbaService - SqlInstance $instance - Type Engine - Force - EnableException
348358 } catch {
@@ -362,6 +372,7 @@ function Set-DbaNetworkCertificate {
362372 ComputerName = $certTest.ComputerName
363373 InstanceName = $certTest.InstanceName
364374 SqlInstance = $certTest.SqlInstance
375+ ServiceAccount = $result.ServiceAccount
365376 CertificateThumbprint = $newThumbprint
366377 Notes = $notes
367378 }
0 commit comments