So I'm at a loss, We are trying to setup a post job script that will run on all of our Veeam jobs. Here is what I have so far:
$postscript = New-VBRjobscriptOptions -PostScriptEnabled -PostCommand "Powershell.exe -File C:\*****"
$job = Get-VBRJob
When I print the value of postscript all of the values are correct. However, I cannot figure out how to apply this setting to the backup jobs I though it could be set by using the Set-VBRJobOptions command however I get the following message when I try this: Set-VBRJobOptions -Job $job -Options $postscript
Set-VBRJobOptions : Cannot bind parameter 'Options'. Cannot convert the
"Veeam.Backup.PowerShell.Infos.VBRJobScriptOptions" value of type "Veeam.Backup.PowerShell.Infos.VBRJobScriptOptions"
to type "Veeam.Backup.Model.CJobOptions".
Do i need to convert this object to a CJobOptions object? If so how can i do that?
Has anyone had any better luck setting a post job script? Is there a different set of commands I can use to set these parameters? from the PowerShell reference there doesn't appear to be a set command for the VBRJobScriptOptions object....
http://helpcenter.veeam.com/backup/powe ... tions.html
Any help would be appreciated.
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Apr 02, 2015 3:52 pm
- Full Name: Andrew Amason
- Contact:
-
- Product Manager
- Posts: 20406
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Set VBRJobScriptOptions
The mentioned cmdlet has to do with tape jobs, not with ordinary backup ones.
In order to change post-job activity settings on existing job, try the following script:
Thanks.
In order to change post-job activity settings on existing job, try the following script:
Code: Select all
asnp VeeamPSSnapin
$Job = Get-VBRJob | ?{$_.Name –eq “Name of your Job”}
$jo = $job.GetOptions()
$jo.PostJobCommand.Enabled = $True
$jo.PostJobCommand.Commandline = "c:\script.bat"
$job.SetOptions($jo)
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Apr 02, 2015 3:52 pm
- Full Name: Andrew Amason
- Contact:
Re: Set VBRJobScriptOptions
Thanks! I ended up making a few modifications to what you sent as i needed to be able to modify all of our VBR jobs but, I've got it all configured now. These options didn't work for me.
I was able to find the correct options though; Here's what I ended up using:
Thanks for all your help! I hope this helps others in the future too.
Code: Select all
$jo.PostJobCommand.Enabled = $True
$jo.PostJobCommand.Commandline = "c:\script.bat"
I was able to find the correct options though; Here's what I ended up using:
Code: Select all
asnp VeeamPSSnapin
$VeeamJobs = Get-VBRJob
$VeeamJobs | Format-Table -AutoSize
foreach ($row in $VeeamJobs) {
$job = Get-VBRJob | ?{$_.Name –eq $row.Name}
$jo = $job.GetOptions()
$jo.JobScriptCommand.PostScriptEnabled = $True
$jo.JobScriptCommand.PostScriptCommandLine = "Powershell.exe -File C:\script.ps1"
$job.SetOptions($jo)
}
-
- Product Manager
- Posts: 20406
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Set VBRJobScriptOptions
Correct, something has changed since the time when I wrote that script. However, I'm glad it gave your the right directions. Thanks for sharing the final result; appreciated.
Who is online
Users browsing this forum: No registered users and 6 guests