PowerShell script exchange
christopher-swe
Service Provider
Posts: 21 Liked: 1 time
Joined: Dec 14, 2016 6:54 am
Full Name: Christopher Svensson
Contact:
Post
by christopher-swe » Dec 14, 2016 6:59 am
this post
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:
Post
by veremin » Dec 14, 2016 10:56 am
this post
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:
Post
by Vitaliy S. » Dec 14, 2016 5:06 pm
this post
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:
Post
by christopher-swe » Jan 26, 2017 10:44 am
this post
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
andreac
Lurker
Posts: 1 Liked: never
Joined: Apr 11, 2016 7:28 pm
Full Name: Andrea Cuozzo
Contact:
Post
by andreac » Feb 20, 2017 3:29 pm
this post
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:
Post
by Vitaliy S. » Feb 21, 2017 10:56 am
this post
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:
Post
by veremin » Feb 21, 2017 12:02 pm
this post
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.
Users browsing this forum: Semrush [Bot] and 10 guests