PowerShell script exchange
Post Reply
Dexiner
Novice
Posts: 6
Liked: never
Joined: Oct 04, 2019 1:15 pm
Full Name: AAAA
Contact:

How to filter by error code from a PS report?

Post by Dexiner »

Hi,
What I need is a Powershell script that gets the entire report of the backup job, and after I need to send by mail the errors.
The problem is that I don't want to send all the errors but just some of them, so I need something that gets the error code and filters it (I don't know, maybe by the code-error would be fine).
So, how can I filter errors by their error code?
chris.arceneaux
VeeaMVP
Posts: 668
Liked: 359 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: How to filter by error code from a PS report?

Post by chris.arceneaux » 2 people like this post

Welcome to the Veeam forums!

There is a similar post answering this question: powershell-f26/get-warning-failed-and-e ... 39599.html

TLDR; The code below will return the errors you're looking for. You can apply PowerShell filtering methods to the output to get your desired results.

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
}
Dexiner
Novice
Posts: 6
Liked: never
Joined: Oct 04, 2019 1:15 pm
Full Name: AAAA
Contact:

Re: How to filter by error code from a PS report?

Post by Dexiner »

Ok that could help me.
So the best way is to use this part of code, (which gets all kind of errors/failures) and apply a Powershell filter.
What I need now is the parameter I need to use to give to Powershell the error code, so I can make a filter.
chris.arceneaux
VeeaMVP
Posts: 668
Liked: 359 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: How to filter by error code from a PS report?

Post by chris.arceneaux »

The code above provides the error in string format. You'll need to filter out the error(s) that you want to exclude/include based of of that string.

For example:

Image
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests