0

I'm trying to use this function Get-VSBSession to get error message of failed VM's in SureBackup.

This is my script:

$vbrsessions = Get-VSBSession | ?{$_.result -ne "success"}
foreach ($session in $vbrsessions)
{ 
    foreach ($failedVM in $session.GetTaskSessionsByResult(("failed")))
   {
       Write-Host "Job Name:" $failedVM.JobName
       Write-Host "Status:" $FailedVM.Info.Result 
       Write-Host "VM:" $failedVM.Name
       Write-Host "Error:" ???
   }
} 

What is the command to get the error message?

Thanks

  • 1
    Are you just trying to find the name of the property which contains the error data? If that is the case, pipe your `$session.GetTaskSessionByResult` output to `Get-Member` like so: `$session.GetTaskSessionByResult() | Get-Member` to see all of the available properties. One of them may be what you're looking for. – Dusty Vargas Oct 28 '19 at 21:10

1 Answers1

0
$vbrsessions = Get-VSBSession | ?{$_.result -ne "success"}
foreach ($session in $vbrsessions)
{ 
    foreach ($failedVM in $session.GetTaskSessionsByResult(("failed")))
   {
       Write-Host "Job Name:" $failedVM.JobName
       Write-Host "Status:" $FailedVM.Info.Result 
       Write-Host "VM:" $failedVM.Name
       Write-Host "Error: $(($failedVM.Logger.GetLog().UpdatedRecords | where Status -ne "ESucceeded" | select -ExpandProperty Title) -join ", ")"
   }
}
t1meless
  • 504
  • 2
  • 9