PowerShell script exchange
Post Reply
tigattack
Influencer
Posts: 11
Liked: never
Joined: Feb 20, 2018 10:06 am
Contact:

Getting VBR job type

Post by tigattack »

Hello all.

I'm working on a script which pulls a bunch of information about a job.

I was previously using this at the beginning of the script to get the initial job details:

Code: Select all

$parentPID = (Get-WmiObject Win32_Process -Filter "processid='$pid'").parentprocessid.ToString()
$parentCmd = (Get-WmiObject Win32_Process -Filter "processid='$parentPID'").CommandLine
$job = Get-VBRJob | Where-Object{$parentCmd -like "*"+$_.Id.ToString()+"*"}
As found here veeam-backup-replication-f2/variables-f ... ml#p141481

However, I now see that the "Get-VBRJob" cmdlet is obsolete.

What cmdlet can I use instead which will get details about VM jobs and Agent jobs? Or how can I tell the difference between them, before calling the Get-VBRJob cmdlet, so I then know to use either Get-VBRJob or Get-VBRComputerBackupJob?

Any pointers would be much appreciated.
Cheers, tig.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Getting VBR job type

Post by oleg.feoktistov » 1 person likes this post

Hi and Welcome to the Community Forums!

Get-VBRJob cmdlet is obsolete for agent jobs only. You need to use Get-VBRComputerBackupJob and Get-VBRComputerBackupCopyJob instead to retrieve more relevant info.
You can filter them all out by JobType primarily to writing to a variable:

Code: Select all

$job = Get-VBRJob -WarningAction SilentlyContinue | Where-Object {$_.JobType -ne 'EpAgentBackup' -and $_.JobType -ne 'EpAgentPolicy'}
$computerJob = Get-VBRComputerBackupJob
$computerCopyJob = Get-VBRComputerBackupCopyJob 
Since filtering happens after retrieving all jobs, there is no way to suppress warning other than to hide it with WarningAction parameter.

Hope that helps.

Oleg
meelisn
Influencer
Posts: 17
Liked: never
Joined: Jun 09, 2020 2:21 pm
Full Name: Meelis Nigols
Contact:

Re: Getting VBR job type

Post by meelisn »

would it be possible to add -JobType parameter to Get-VBRJob to avoid this warning? It would also make searching specific type of jobs a lot easier ...

Meelis
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Getting VBR job type

Post by oleg.feoktistov »

That's what the parameter set below is for:

Code: Select all

-WarningAction SilentlyContinue
Honestly, I don't see a huge benefit from -JobType parameter as it covers a single job type inclusion at a time.
When it would come to retrieving jobs of several job types or excluding one, you would still need to use where-object filtering.
But maybe I'm wrong?

Thanks,
Oleg
meelisn
Influencer
Posts: 17
Liked: never
Joined: Jun 09, 2020 2:21 pm
Full Name: Meelis Nigols
Contact:

Re: Getting VBR job type

Post by meelisn »

when i need for example only those few backup copy jobs from 100 of all, that would be huge benefit. Especially because Snapin could filter those jobs, not my script. And it could save network traffic when script connects over network ...

Being able to filter jobs by ID would also be a huge benefit, when ID is known. Or by being scheduled ( like

Code: Select all

-Scheduled <SwitchParameter>
on command line)

Meelis
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Getting VBR job type

Post by oleg.feoktistov » 2 people like this post

Hi Meelis,

In current circumstances implementing -JobType parameter won't help neither with preventing a warning from appearing, nor with saving network traffic - all jobs retrieved with Get-VBRJob are of CBackupJob type. So, to filter them it would still involve parsing them all first.
But you gave me an idea on how it can be solved on the backend. I just need to discuss it with developers.
Also noted your suggestions on -Id and -Scheduled options.

Thanks and Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests