PowerShell script exchange
Post Reply
EWMarco
Service Provider
Posts: 39
Liked: 7 times
Joined: Feb 20, 2023 9:28 am
Full Name: Marco Glavas
Contact:

How to manage jobs in the "Running" View

Post by EWMarco »

Hi everyone

For reasons I'm not going to get into right now, I spend a lot of time manually killing SOBR Offload jobs.

I was wondering if I could automate this with powershell.

Is there a way to get a list of jobs currently in the "Running" pane of the GUI and killing them by name? I need jobs that are in Running, Starting or Waiting for...resources states.

It would be QUITE the bonus if we could extract the jobs' IDs so we could also terminate the corresponding processes if necessary.

Thanks for your input.
oleg.feoktistov
Veeam Software
Posts: 1891
Liked: 631 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: How to manage jobs in the "Running" View

Post by oleg.feoktistov »

Hi Marco,

You can get all backup sessions and filter them out by not "Stopped" state:

Code: Select all

$sessions = Get-VBRBackupSession | where {$_.State -ne 'Stopped'}
$sessions
That will pretty much imitate the "Running" pane.


To filter sessions by other states, take a look at the available states in the following enum:

Code: Select all

[Veeam.Backup.Model.CBaseSessionInfo+EState].GetEnumValues()
To extract Job id from session object, access this property:

Code: Select all

$sessions[0].JobId
Hope that helps,
Oleg
EWMarco
Service Provider
Posts: 39
Liked: 7 times
Joined: Feb 20, 2023 9:28 am
Full Name: Marco Glavas
Contact:

Re: How to manage jobs in the "Running" View

Post by EWMarco »

Unfortunately, that is not a solution to my problem. The software seems to make a difference between Offloading Jobs and everything else. I have about 80 jobs in the GUI view but this command only returns like four.
EWMarco
Service Provider
Posts: 39
Liked: 7 times
Joined: Feb 20, 2023 9:28 am
Full Name: Marco Glavas
Contact:

Re: How to manage jobs in the "Running" View

Post by EWMarco »

Can I assume Offload Job management has kinda been forgotten by the PowerShell devs at this point? ;)
oleg.feoktistov
Veeam Software
Posts: 1891
Liked: 631 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: How to manage jobs in the "Running" View

Post by oleg.feoktistov »

Forgotten - no, planned for future versions - yes. My bad, I forgot that the main point was about offload sessions. They are not, indeed, exposed with the official cmdlets, but you can still get them with unsupported methods.
For instance, the method below will return running sessions only thus emulating Running pane precisely + it will show shell run sessions:

Code: Select all

$runningSessions = [Veeam.Backup.Core.CBaseSession]::GetRunning()
$runningSessions
Further on, make sure to filter them by job type and not abort the shell run sessions. You can get job types here:

Code: Select all

[Veeam.Backup.Model.EDbJobType].GetEnumValues()
The values that are related to offload all start with Archive.

Thanks,
Oleg
EWMarco
Service Provider
Posts: 39
Liked: 7 times
Joined: Feb 20, 2023 9:28 am
Full Name: Marco Glavas
Contact:

Re: How to manage jobs in the "Running" View

Post by EWMarco »

Thank you, this looks very promising.

I have one little issue: When running this on a fresh session I get an error.
Exception calling "GetRunning" with "0" argument(s): "Database connection was closed"

Can you tell me how to open and close the DB session? I've tried a simple connect-vbrserver but that doesn't seem to work when running the script.
david.domask
VeeaMVP
Posts: 1015
Liked: 276 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to manage jobs in the "Running" View

Post by david.domask »

Hey @EWMarco

After Connect-VBRServer, run any cmdlet first and just pipe the output to NULL

Get-VBRLicenseAutoUpdateStatus | Out-Null

The method Oleg mentioned is .NET Reflection, and it calls the DLLs directly; sometimes they need a chance to get "hot", but running a cmdlet should do it.

In my lab, even with a script, it works fine just by doing a quick call.
David Domask | Director: Customer Care | Veeam Technical Support
EWMarco
Service Provider
Posts: 39
Liked: 7 times
Joined: Feb 20, 2023 9:28 am
Full Name: Marco Glavas
Contact:

Re: How to manage jobs in the "Running" View

Post by EWMarco »

Thank you!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest