Get Warning, Failed and Error messages

PowerShell script exchange

Get Warning, Failed and Error messages

Veeam Logoby christopher-swe » Wed Dec 14, 2016 6:59 am

Hello,

Iv'e been searching far and wide on how to extract the error messages with PowerShell from veeam when your job fails.

I found this from a post from 2011, with a bit of code, but it doesn't seem to work now.
Code: Select all
$Info = [Veeam.Backup.Core.CBackupTaskSession]::GetByJobSession($session.id)
$Info[0].Reason


Is there someone who can point me in the right direction or is this impossible to get?
I'm using Veeam Backup & Replication 9.0

Best Regards Christopher
christopher-swe
Novice
 
Posts: 5
Liked: 1 time
Joined: Wed Dec 14, 2016 6:54 am
Full Name: Christopher Svensson

Re: Get Warning, Failed and Error messages

Veeam Logoby v.Eremin » Wed Dec 14, 2016 10:56 am

There might be different places where an error is reported (task session, job session, etc.). So, can you provide a screenshot to illustrate the idea better? Thanks.
v.Eremin
Veeam Software
 
Posts: 13702
Liked: 1020 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get Warning, Failed and Error messages

Veeam Logoby Vitaliy S. » Wed Dec 14, 2016 5:06 pm

Do you possibly look for something like we display in the predefined report of Veeam ONE > Latest Backup Job Status?
Vitaliy S.
Veeam Software
 
Posts: 19945
Liked: 1144 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Get Warning, Failed and Error messages

Veeam Logoby christopher-swe » Thu Jan 26, 2017 10:44 am

Sorry for the late feed-back, some stuff got in my way.

I partially found what I was looking for, and the solution was to check in Windows Event viewer in order to get the full warning messages.

Code: Select all
$BackupJobs = Get-VBRJob
foreach ($Job in $BackupJobs) {
    Get-WinEvent -FilterHashtable @{Logname='Veeam Backup';ID=190} |Select-Object Message | Select-String -Pattern $Job.Name | select -First 1
}


I hope this will help some one i the future :D
christopher-swe
Novice
 
Posts: 5
Liked: 1 time
Joined: Wed Dec 14, 2016 6:54 am
Full Name: Christopher Svensson

Re: Get Warning, Failed and Error messages

Veeam Logoby andreac » Mon Feb 20, 2017 3:29 pm

Thanks Cristopher, it helped me a lot! I was using the same syntax as the first message of this topic to get to the jobs error/warning message, but it's not 100% precise with the failed job descriptions, and it can't retrieve 90% of the warning job descriptions. I'm querying Veeam 8, 9, and 9.5.

Since querying the eventlog can be painfully slow, I'd still like to know if Veeam cmdlets can retrieve this information.
andreac
Lurker
 
Posts: 1
Liked: never
Joined: Mon Apr 11, 2016 7:28 pm
Full Name: Andrea Cuozzo

Re: Get Warning, Failed and Error messages

Veeam Logoby Vitaliy S. » Tue Feb 21, 2017 10:56 am

Hi Andrea,

Can you please tell us a bit more about your use case? Do you parse these messages and then send them to another portal or monitoring application?

Thanks!
Vitaliy S.
Veeam Software
 
Posts: 19945
Liked: 1144 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Get Warning, Failed and Error messages

Veeam Logoby v.Eremin » Tue Feb 21, 2017 12:02 pm

Since querying the eventlog can be painfully slow, I'd still like to know if Veeam cmdlets can retrieve this information.

Can you elaborate on what particular information you're after?

For instance, if you want to capture error messages job failed with, you can use something similar:

Code: Select all
Asnp VEeamPSSnapin
$Sessions = Get-VBRBackupSession -Name "Job Name" | where {$_.Result -eq "Failed"}
foreach ($Session in $Sessions){
$Session[0].Logger.GetLog().updatedrecords | ?{$_.status -eq "EFailed"} | select title
}


Thanks.
v.Eremin
Veeam Software
 
Posts: 13702
Liked: 1020 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 1 guest