PowerShell script exchange
Post Reply
can
Influencer
Posts: 10
Liked: 2 times
Joined: Apr 25, 2024 8:13 am
Full Name: can bilgiç
Contact:

how to find the job that triggers itself from veeam pre-script

Post by can »

Hello,

I'm working on a Veeam powershell script and I ran into the following problem:
When I trigger a backupjob, the pre-script should have access to the information of the job that triggered itself, for example backupjobId, description ... and based on this information it should perform operations and redirect them to the post-script. Is there any mechanism in the pre-script to understand which job is the job that triggered itself?

Thank you.
david.domask
Veeam Software
Posts: 2163
Liked: 519 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: how to find the job that triggers itself from veeam pre-script

Post by david.domask » 1 person likes this post

Hi can,

This code should work:

Code: Select all

$ScriptPID = Get-WMIObject win32_process | Where-Object {$_.ProcessID -eq $PID}
$ParentProc = Get-WMIObject win32_process | Where-Object {$_.ProcessID -eq $ScriptPID.ParentProcessId}
$JobID = $ParentProc.CommandLine.Split()[7].Trim('"')
$Job = Get-VBRJob | Where-Object {$_.id -eq $JobID}
End result with be a CJob object returned by Get-VBRJob and from there you can write code to do whatever you like with the CJob object.

Can you elaborate on your workflow a bit more? There really isn't a way for the pre/post job scripts to pass objects/variables to one another, you'd need to write it to a file and import the file between scripts, but this seems cumbersome. What is your intended workflow?
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests