Latest update

This commit is contained in:
2026-06-24 12:28:01 +01:00
parent c09a05a129
commit ae9f794377
7 changed files with 311 additions and 552 deletions
+31 -4
View File
@@ -93,7 +93,8 @@ function Get-ExceptionMessageList {
function Write-ExceptionDiagnostics {
param(
[string]$Prefix,
[System.Exception]$Exception
[System.Exception]$Exception,
[System.Management.Automation.ErrorRecord]$ErrorRecord
)
if (-not $Exception) {
@@ -101,7 +102,8 @@ function Write-ExceptionDiagnostics {
return
}
$detailLines = Get-ExceptionMessageList -Exception $Exception
# Force array semantics so single detail lines are not treated as scalar strings.
$detailLines = @(Get-ExceptionMessageList -Exception $Exception)
if ($detailLines.Count -eq 0) {
Write-Log "ERROR: $Prefix $($Exception.Message)"
return
@@ -111,6 +113,31 @@ function Write-ExceptionDiagnostics {
for ($i = 1; $i -lt $detailLines.Count; $i++) {
Write-Log "ERROR: detail[$i]: $($detailLines[$i])"
}
if ($ErrorRecord) {
if ($ErrorRecord.FullyQualifiedErrorId) {
Write-Log "ERROR: FullyQualifiedErrorId: $($ErrorRecord.FullyQualifiedErrorId)"
}
if ($ErrorRecord.CategoryInfo) {
Write-Log "ERROR: CategoryInfo: $($ErrorRecord.CategoryInfo)"
}
$recordText = $ErrorRecord.ToString()
if (-not [string]::IsNullOrWhiteSpace($recordText)) {
$recordLines = @($recordText -split "`r?`n" | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
foreach ($line in $recordLines) {
Write-Log "ERROR: Record: $line"
}
}
}
$exceptionText = $Exception.ToString()
if (-not [string]::IsNullOrWhiteSpace($exceptionText)) {
$exceptionLines = @($exceptionText -split "`r?`n" | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
foreach ($line in $exceptionLines) {
Write-Log "ERROR: Exception: $line"
}
}
}
function Test-ServiceAccountFile {
@@ -153,7 +180,7 @@ function Connect-RscWithDiagnostics {
Write-Log "INFO: $Context Connected to Rubrik Security Cloud."
} catch {
$prefix = "($Context Connect-Rsc -ServiceAccountFile $ServiceAccountFile) failed."
Write-ExceptionDiagnostics -Prefix $prefix -Exception $_.Exception
Write-ExceptionDiagnostics -Prefix $prefix -Exception $_.Exception -ErrorRecord $_
Write-Log "ERROR: Troubleshooting hints: verify file permissions/content, outbound HTTPS connectivity, proxy configuration, and local system time sync."
throw
}
@@ -379,7 +406,7 @@ try {
}
Write-Log "INFO: Retrieved paths: $($paths -join ', ')"
} catch {
Write-ExceptionDiagnostics -Prefix "Failed to retrieve paths from Rubrik." -Exception $_.Exception
Write-ExceptionDiagnostics -Prefix "Failed to retrieve paths from Rubrik." -Exception $_.Exception -ErrorRecord $_
exit 1
}