PowerShell script exchange
Post Reply
jcwuerfl
Enthusiast
Posts: 44
Liked: 4 times
Joined: Jun 29, 2011 8:26 pm
Full Name: James
Contact:

Add-VBRCopyJob

Post by jcwuerfl »

Was Looking for a way to automate adding a bunch of copy jobs and it looks like you can do : Add-VBRCopyJob

When I tried this:

Code: Select all

Add-VBRCopyJob -Name "CopyJobName" -Type VDDK -Server $host  "e:\veeam" -Objects myVMServerName
Basically gave an error

Cannot bind parameter 'Server'. Cannot convert the "System.Management.Automation.Internal.Host.InternalHost" value of type "System.Management.Automation.Internal.Host.InternalHost" to type "Veeam.Backup.Core.CHost".

So sort of figured out it was needing a Object type reference from get-vbrserver

So I tried:

Code: Select all

$VeeamServer = get-vbrserver -name "This Server"
Add-VBRCopyJob -Name "CopyJobName" -Type VDDK -Server $VeeamServer "e:\veeam" -Objects myVMServerName
Which worked however, it didn't really pick the right option for where it was going to store it. It still picked the Default Backup Repository instead of "Server, e:\veeam"

Also looking for a way to run and check the status of the copy job as well.

Thanks
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Add-VBRCopyJob

Post by ThomasMc »

It would look more like this

Code: Select all

Add-VBRCopyJob -Name "CopyJobName" -Type VDDK -Server $VeeamServer -Folder "e:\veeam" -Objects myVMServerName
unfortunately this is one of the cmdlets that need more work done to it for v6 as it does some weirdness like trying to login to you repositories via soap which will generate errors when adding a new job, for the second part you could use something like below

Code: Select all

# Fetch the job
$Job = Get-VBRJob -Name "CopyJobName"
# Start the job
$Job| Start-VBRJob
# Loop until done
do {sleep 10}
while ($Job.GetLastState() -ne "stopped")
# Print status
"$($Job.Name) is $($Job.GetLastState())" | Out-Default
jcwuerfl
Enthusiast
Posts: 44
Liked: 4 times
Joined: Jun 29, 2011 8:26 pm
Full Name: James
Contact:

Re: Add-VBRCopyJob

Post by jcwuerfl »

So the problem I see is that when I look at the job is that it seems to be going to the Default Repository?

I noticed that in $job.info that there was a:

TargetRepositoryId : 88788f9e-d8f5-4eb4-bc4f-9b3f5403bcec

But when I change the option through the Gui under storage from Backup to Server (Radio Button) the TargetRepositoryID changes to:

TargetRepositoryId : 00000000-0000-0000-0000-000000000000

I do have to reset the job object to see the updated information. aka
$job = get-vbrjob -name "$vmName-cp"

Is there a way to change the Storage Target Repository ... i.e that Radio Button option from Backup to Server ?

I was thinking that these should all really be setup as Target Repositories and I have one of those for this folder instead of dealing with this other object for "This Server" ?

Thanks for your help, very much appreciate it.
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Add-VBRCopyJob

Post by ThomasMc »

I've not found how to do it in the current cmdlets, there should have been new parameters added to the v6 version like -Repository and -Entity on the Add-VBRCopyJob cmdlet to deal with it or even a new one added, maybe Seth will know how to change it
jcwuerfl
Enthusiast
Posts: 44
Liked: 4 times
Joined: Jun 29, 2011 8:26 pm
Full Name: James
Contact:

Re: Add-VBRCopyJob

Post by jcwuerfl » 1 person likes this post

Another thing I noticed that you can see what the Target Repository is but still don't understand how you can change it for a job.

$job.GetTargetRepository()

Name Type Host Path Description
---- ---- ---- ---- -----------
Default Backup Repository WinLocal This server c:\backup Created by Veeam Backup
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests