PowerShell script exchange
Post Reply
christopher-swe
Service Provider
Posts: 21
Liked: 1 time
Joined: Dec 14, 2016 6:54 am
Full Name: Christopher Svensson
Contact:

Get Warning, Failed and Error messages

Post by christopher-swe »

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
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Warning, Failed and Error messages

Post by veremin »

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.
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Get Warning, Failed and Error messages

Post by Vitaliy S. »

Do you possibly look for something like we display in the predefined report of Veeam ONE > Latest Backup Job Status?
christopher-swe
Service Provider
Posts: 21
Liked: 1 time
Joined: Dec 14, 2016 6:54 am
Full Name: Christopher Svensson
Contact:

Re: Get Warning, Failed and Error messages

Post by christopher-swe »

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
andreac
Lurker
Posts: 1
Liked: never
Joined: Apr 11, 2016 7:28 pm
Full Name: Andrea Cuozzo
Contact:

Re: Get Warning, Failed and Error messages

Post by andreac »

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.
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Get Warning, Failed and Error messages

Post by Vitaliy S. »

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!
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Warning, Failed and Error messages

Post by veremin »

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.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 10 guests