PowerShell script exchange
Post Reply
soda39
Influencer
Posts: 14
Liked: never
Joined: Aug 16, 2023 1:44 pm
Contact:

get ALL failed jobs 24h/get tape content incl. NAS backups etc.

Post by soda39 »

Hi community,

I know, there are plenty of posts and topics on that one. But it seems that I found no posts for my specific case. If there is one, please refer to it. Thanks in advance.

What it is about:
1. The main goal is to achieve a list of ALL jobs from the last 24 hours and filter in this list. Exactly like when you click on "Last 24 hours" in the "Home" section of B&R Console. I tried to get all jobs, including backup jobs like NAS jobs, agent (windows/linux) jobs, VM jobs and also copy jobs like backup and file copy jobs etc. - in other words, really ALL jobs, like Get-VBRJobs did. Unfortunately the command you should use instead (Get-VBRComputerBackupJob) does only list backup jobs of machines with installed Veeam agent (windows/linux). I found out that I can use multiple commands additional to the Get-VBRComputerBackupJob command, like Get-VBRNASBackupJob. But since that is not really, let's say practical, for coding a monitoring check. Also because those commands, especially Get-VBRComputerBackupJob is so slow, that the monitoring tool times out... So after hours of Google and trying different commands, I thought, lets just use Get-VBRJobs until it really gets removed, foreach through all the jobs and filter for LatestRunLocal, ONLY to determine that the date is completely off of the REAL last run I can see in the B&R Console.
Also I would like to say that Get-VBRComputerBackupJob lists jobs twice, for whatever reason and some do not get displayed etc.

Can someone please tell me how I correctly get all jobs with the last run date in a sustainable way? Or something I can filter through or whatever. Is there a documentation of which commands I really need to achieve a list of ALL jobs as described?

2. We would like document which jobs wrote on which tape. Is there an easy way of listing tape contents, like when opening the properties of a tape and navigating to the tab "Files". And no, I don't mean in the way the script of Stephan Herzig does, since this only lists which .vbk files are on which tape, because we also have NAS (managed Fileserver) backups going to tape.

Thanks in advance. Hopefully I explained it accurate enough.

BR Daniel
david.domask
Veeam Software
Posts: 2340
Liked: 554 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: get ALL failed jobs 24h/get tape content incl. NAS backups etc.

Post by david.domask »

Hi @soda39, try making a generics list in PS and then just adding to the list using Get-VBRSession with the desired types on the -Type paramter.

For example, you could do something like:

Code: Select all

$jobTypes = @(‘Backup’,’Replica’,’Copy’,’VMTapeBackup’)
$AllJobSess =  [System.Collections.Generic.List[PSObject]]@()
Foreach($jt in $jobTypes){
     $sess = Get-VBRSession -Type $jt #here you will want to pipe to Sort-Object and make a filter for the desired creationtime
     $AllJobSess.Add($sess)
}
All the sessions returned by Get-VBRSession will have a JobID parameter, so you can potentially filter on that.

Else, you will need to use the various Get-*Session cmdlets one by one; but I kind of like my method to get the sessions as with the piping and filtering, it should be faster and also much easier to just do the necessary lookups based on the JobIDs to get the Job Names.
David Domask | Product Management: Principal Analyst
soda39
Influencer
Posts: 14
Liked: never
Joined: Aug 16, 2023 1:44 pm
Contact:

Re: get ALL failed jobs 24h/get tape content incl. NAS backups etc.

Post by soda39 »

Hi David,

Thank you for your answer, I will give it a try asap.

BR
soda39
Influencer
Posts: 14
Liked: never
Joined: Aug 16, 2023 1:44 pm
Contact:

Re: get ALL failed jobs 24h/get tape content incl. NAS backups etc.

Post by soda39 »

Hi David,

Got it, it's pretty much what I was looking for. Thanks a lot! Get-VBRRestoreSession also opened another door for automating a lot things for us, so thanks again!

BR Daniel
david.domask
Veeam Software
Posts: 2340
Liked: 554 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: get ALL failed jobs 24h/get tape content incl. NAS backups etc.

Post by david.domask »

@soda39, glad to hear it, and glad that the *Session cmdlets are helpful for your automation!

If you don't mind, would love to see your scripts but ofc no need, just glad it worked!
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests