Just a small code example for changing a VM datastore target in a replica job. You can change disk type ( thin / thick ) as well.
This code is based on v.Eremin's (Vladimir Eremin) example. Credit go to him.
Code: Select all
asnp VeeamPSSnapin
$JobnName = "testrep3"
$VmwareName = "esxi55u1"
$VMName = "empty"
$NewDatastoreName = "ds1-small"
$TargetDiskCreationMode = "Thin" #"Thick" or "Thin"
$VmwareObject = Get-VBRServer | where {$_.Name -eq $VmwareName}
$ds = Find-VBRViDatastore -Server ($VmwareObject) | where {$_.Name -eq $NewDatastoreName}
$JobObject = Get-VBRJob -name $JobnName
$Options = $JobObject.GetOptions()
$Objects = $JobObject.GetObjectsInJob()
$SelectedObject = $Objects | where { $_.Name -eq $VMName }
$SelectedObjectInfo = $SelectedObject.Info
#Set Config File Target Location
$SelectedObjectInfo.ExtendedOptions.TargetOptions.TargetDatastoreName = $ds.Name
$SelectedObjectInfo.ExtendedOptions.TargetOptions.TargetDatastoreRef = $ds.Reference
#Set First Disk Target Location
$SelectedObjectInfo.ExtendedOptions.TargetOptions.DiskDestination[0].TargetDatastoreName = $ds.Name
$SelectedObjectInfo.ExtendedOptions.TargetOptions.DiskDestination[0].TargetDatastoreRef = $ds.Reference
$SelectedObjectInfo.ExtendedOptions.TargetOptions.DiskDestination[0].DiskCreationMode = $TargetDiskCreationMode
#Write Config
[Veeam.Backup.Core.CObjectInJob]::Update($SelectedObjectInfo)