Quantcast
Channel: R&D Forums
Viewing all articles
Browse latest Browse all 9954

PowerShell • Re: Stop job pre-job script

$
0
0
Hi bctak25, welcome to the forums.

> Is there a way to abort the calling job depending on the powershell exit code or another method?

No direct way, but you can use native powershell methods to find the calling job:

Code:

$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}
From there I suppose you can pass the job to Stop-VBRJob to stop the job.

> Is there a way to pass a message to the warning email instead of "Pre-job script terminated with exit code 1" ?

Not within Veeam. Veeam simply passes the provided script and has the host OS execute it, and then Veeam responds based on the exit code. You can exit your script with a custom exit code in Powershell to pass some information in the exit code.

Statistics: Posted by david.domask — Jun 30, 2025 8:20 am



Viewing all articles
Browse latest Browse all 9954

Latest Images

Trending Articles



Latest Images