Possible PowerShell Command Issue

PowerShell script exchange

Re: Possible PowerShell Command Issue

Veeam Logoby zuldan » Thu Mar 16, 2017 10:53 am

Thanks v.Eremin I managed to get it working. I've included the modified code below in case anyone else has the issue.

Would you like me to open a case for this bug or will it be fixed along with the rest of the tape cmdlet fixes?

Code: Select all
Add-PSSnapin -Name VeeamPSSnapIn

$TapePool = 'Onsite Tapes'

$JobList = Get-VBRJob | Where-Object -FilterScript { $PSItem.JobTargetType -eq 'Backup' }

foreach ($Job in $JobList)
    if ($null -eq (Get-VBRTapeJob -Name "$TapePool - $($Job.Name)" -ErrorAction SilentlyContinue))
        Write-Host -Object "`nCreating tape job: $TapePool - $($Job.Name)"
        Write-host -Object "$TapePool - $($Job.Name): Adding $($Job.Name)"

        # Create Tape Job and add backup job
        $Mediapool = Get-VBRTapeMediaPool -Name $TapePool
        $TapeJob = Add-VBRBackupToTapeJob -Name "$TapePool - $($Job.Name)" -Object $Job -FullBackupMediaPool $Mediapool -ProcessIncrementalBackup -IncrementalBackupMediaPool $Mediapool -ExportDays Friday -AlwaysCopyFromLatestFull
        # Configure Tape Job to start after backup job
        $TapeSchedule = New-VBRBackupToTapeScheduleOptions -Type AfterJob -Job $Job -Enabled

        # AlwaysCopyFromLastestFull used here again because Set-VBRBackupToTapeJob clears the option
        $TapeJob | Set-VBRBackupToTapeJob -ScheduleOptions $TapeSchedule -AlwaysCopyFromLatestFull
Posts: 45
Liked: 5 times
Joined: Wed Feb 15, 2017 9:51 am

Re: Possible PowerShell Command Issue

Veeam Logoby v.Eremin » Thu Mar 16, 2017 11:29 am

It seems to be a general problem with Set-VBRBackupToTape job that this cmdlet resets all settings besides those that are specified. We're well aware of this issue and going to address it in one of the next product releases. Thanks.
Veeam Software
Posts: 14722
Liked: 1102 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] Adding job to tape job is changing schedule

Veeam Logoby efd121 » Wed Jul 05, 2017 4:01 pm

I'm attempting to add a Backup job to an existing tape job and when I use the code below its changing the job schedule to be After a Backup Job
I don't want this script to change the schedule, it just needs to add a new Backup Job.
The job it added happened to be the first one when sorted alphabetically
The results are the same with or without adding the $SchedOptions object to Set-VBRBackupToTapeJob

$TapeJob = Get-VBRTapeJob -Name <My Job Name>
$NewJob = Get-VBRJob -Name <Job to Add>
$NewObject = $TapeJob.Object
$NewObject += $NewJob
$SchedOptions = $TapeJob.ScheduleOptions
Set-VBRBackupToTapeJob -Job $TapeJob -Object $NewObject -ScheduleOptions $SchedOptions
Posts: 25
Liked: never
Joined: Fri Aug 07, 2015 8:45 pm
Full Name: David Engler


Return to PowerShell

Who is online

Users browsing this forum: ThierryF and 9 guests