Skip to content

Commit b6e7b13

Browse files
updated error handling response
1 parent bbdb8df commit b6e7b13

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Invoke-SqlFailOverDetection.ps1

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ Show = $Show"
227227
}
228228
catch {
229229
Write-Warning "We aren't going to get very far without creating the $DownloadFolder"
230+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
230231
Return
231232
}
232233
}
@@ -238,6 +239,7 @@ Show = $Show"
238239
}
239240
catch {
240241
Write-Warning "We aren't going to get very far without creating the $InstallationFolder"
242+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
241243
Return
242244
}
243245
}
@@ -247,8 +249,9 @@ Show = $Show"
247249
$null = New-Item $DataFolder -ItemType Directory
248250
}
249251
}
250-
catch {
252+
catch {
251253
Write-Warning "We aren't going to get very far without creating the $DataFolder"
254+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
252255
}
253256
}
254257
#endregion
@@ -288,7 +291,8 @@ Show = $Show"
288291
}
289292
}
290293
catch {
291-
Write-Warning "The Beard is sad! There was an error downloading file :( $_"
294+
Write-Warning "The Beard is sad! There was an error downloading file :( "
295+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
292296
return
293297
}
294298
}
@@ -314,6 +318,7 @@ Show = $Show"
314318
}
315319
else {
316320
Write-Warning "Hmm something has gone wrong - where is the zip file? It should be $FilePath"
321+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
317322
Return
318323
}
319324
}
@@ -326,8 +331,9 @@ Show = $Show"
326331
try {
327332
$Ag = Get-DbaAvailabilityGroup -SqlInstance $SQLInstance -AvailabilityGroup $AvailabilityGroup
328333
}
329-
catch {
334+
catch {
330335
Write-Warning "Failed to get the informatio about the Availability Group - Gonna have to stop"
336+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
331337
}
332338

333339
$replicastring = ForEach ($replica in $Ag.AvailabilityReplicas.Name) {
@@ -346,6 +352,7 @@ Show = $Show"
346352
}
347353
catch {
348354
Write-Warning "We aren't going to get very far without creating the folder $InstanceFolder for the data for the replica $Replica"
355+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
349356
Return
350357
}
351358
}
@@ -393,8 +400,9 @@ Show = $Show"
393400
try {
394401
$Errorlogpath = (Get-DbaErrorLogConfig -SqlInstance $replica).LogPath
395402
}
396-
catch {
403+
catch {
397404
Write-Warning "Failed to get the error log path for the replica $replica - Going to be difficult to gather all the data for $replica"
405+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
398406
}
399407

400408
$UNCErrorLogPath = '\\' + $replicaHostName + '\' + $Errorlogpath.Replace(':', '$')
@@ -432,7 +440,9 @@ Show = $Show"
432440
}
433441
}
434442
catch {
443+
435444
Write-Warning "Failed to get all of the information from the replica $replica - need to stop"
445+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
436446
Return
437447
}
438448
}
@@ -449,6 +459,7 @@ Show = $Show"
449459
}
450460
catch {
451461
Write-Warning "Failed to copy the files to the installation folder - Cant carry on"
462+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
452463
return
453464
}
454465

@@ -478,6 +489,7 @@ Show = $Show"
478489
}
479490
catch {
480491
Write-Warning "Failed to create the configuration json file- cant continue"
492+
Write-Warning "Run `$Error[0] | Fl -Force to find out what happened"
481493
}
482494
}
483495

0 commit comments

Comments
 (0)