@@ -88,7 +88,32 @@ Describe 'Initialize-SqlDscRebuildDatabase' -Tag @('Integration_SQL2017', 'Integ
8888 Force = $true
8989 }
9090
91- $null = Initialize-SqlDscRebuildDatabase @rebuildSqlDscDatabaseParameters
91+ try
92+ {
93+ $null = Initialize-SqlDscRebuildDatabase @rebuildSqlDscDatabaseParameters
94+ }
95+ catch
96+ {
97+ # Output Summary.txt if it exists to help diagnose the failure
98+ $summaryFiles = Get-ChildItem - Path ' C:\Program Files\Microsoft SQL Server' - Filter ' Summary.txt' - Recurse - ErrorAction SilentlyContinue |
99+ Where-Object { $_.FullName -match ' \\Setup Bootstrap\\Log\\' } |
100+ Sort-Object - Property LastWriteTime - Descending |
101+ Select-Object - First 1
102+
103+ if ($summaryFiles )
104+ {
105+ Write-Verbose " ==== SQL Server Setup Summary.txt (from $ ( $summaryFiles.FullName ) ) ====" - Verbose
106+ Get-Content - Path $summaryFiles.FullName | Write-Verbose - Verbose
107+ Write-Verbose " ==== End of Summary.txt ====" - Verbose
108+ }
109+ else
110+ {
111+ Write-Verbose ' No Summary.txt file found.' - Verbose
112+ }
113+
114+ # Re-throw the original error
115+ throw $_
116+ }
92117 }
93118
94119 It ' Should have the SQL Server service running after rebuild' {
@@ -134,7 +159,32 @@ Describe 'Initialize-SqlDscRebuildDatabase' -Tag @('Integration_SQL2017', 'Integ
134159 Force = $true
135160 }
136161
137- $null = Initialize-SqlDscRebuildDatabase @rebuildSqlDscDatabaseParameters
162+ try
163+ {
164+ $null = Initialize-SqlDscRebuildDatabase @rebuildSqlDscDatabaseParameters
165+ }
166+ catch
167+ {
168+ # Output Summary.txt if it exists to help diagnose the failure
169+ $summaryFiles = Get-ChildItem - Path ' C:\Program Files\Microsoft SQL Server' - Filter ' Summary.txt' - Recurse - ErrorAction SilentlyContinue |
170+ Where-Object { $_.FullName -match ' \\Setup Bootstrap\\Log\\' } |
171+ Sort-Object - Property LastWriteTime - Descending |
172+ Select-Object - First 1
173+
174+ if ($summaryFiles )
175+ {
176+ Write-Verbose " ==== SQL Server Setup Summary.txt (from $ ( $summaryFiles.FullName ) ) ====" - Verbose
177+ Get-Content - Path $summaryFiles.FullName | Write-Verbose - Verbose
178+ Write-Verbose " ==== End of Summary.txt ====" - Verbose
179+ }
180+ else
181+ {
182+ Write-Verbose ' No Summary.txt file found.' - Verbose
183+ }
184+
185+ # Re-throw the original error
186+ throw $_
187+ }
138188 }
139189
140190 It ' Should have the SQL Server service running after rebuild with TempDB parameters' {
@@ -162,7 +212,32 @@ Describe 'Initialize-SqlDscRebuildDatabase' -Tag @('Integration_SQL2017', 'Integ
162212 Force = $true
163213 }
164214
165- $null = Initialize-SqlDscRebuildDatabase @rebuildSqlDscDatabaseParameters
215+ try
216+ {
217+ $null = Initialize-SqlDscRebuildDatabase @rebuildSqlDscDatabaseParameters
218+ }
219+ catch
220+ {
221+ # Output Summary.txt if it exists to help diagnose the failure
222+ $summaryFiles = Get-ChildItem - Path ' C:\Program Files\Microsoft SQL Server' - Filter ' Summary.txt' - Recurse - ErrorAction SilentlyContinue |
223+ Where-Object { $_.FullName -match ' \\Setup Bootstrap\\Log\\' } |
224+ Sort-Object - Property LastWriteTime - Descending |
225+ Select-Object - First 1
226+
227+ if ($summaryFiles )
228+ {
229+ Write-Verbose " ==== SQL Server Setup Summary.txt (from $ ( $summaryFiles.FullName ) ) ====" - Verbose
230+ Get-Content - Path $summaryFiles.FullName | Write-Verbose - Verbose
231+ Write-Verbose " ==== End of Summary.txt ====" - Verbose
232+ }
233+ else
234+ {
235+ Write-Verbose ' No Summary.txt file found.' - Verbose
236+ }
237+
238+ # Re-throw the original error
239+ throw $_
240+ }
166241 }
167242
168243 It ' Should have the SQL Server service running after rebuild with collation' {
0 commit comments