Add-VBRCopyJob - how to properly specify target as datastore

PowerShell script exchange

Add-VBRCopyJob - how to properly specify target as datastore

Veeam Logoby IonutN » Thu Jun 18, 2015 7:35 am

Hi,

I am trying to write a set of commands that will create a lab environment from a number of VMs. The VMs need to be copied as is from a vCenter to the same vcenter, but other datastores, or to different vCenters alltogether.
For simplicity the code below just copies the VMs to another datastore on a specific host in the same vcenter.
This lab will be needed to be created on demand, so i chose to automate this using Veeam PowerShell snapin.

Code: Select all
$vcenter = "demo-vcenter"
$EntityToCopy = Find-VBRViEntity -Name "VM1" -VMsAndTemplates -Server $vcenter
$sourceServer = Get-VBRServer -Type VC -name $vcenter

$server = Get-VBRServer -Type ESXi -name "ESX01.demo"

$viableDS = Find-VBRViDatastore -Server $server | ? {$_.FreeSpace -gt $EntityToCopy.ProvisionedSize } | sort FreeSpace -Descending | select -First 1

Add-VBRCopyJob -Name "VM1-To-Sandbox" -Type VDDK -Server $server -folder $viableDS -SourceServer $sourceServer -Objects $EntityToCopy.Name -Description "test" -Verbose


And i get this error
Code: Select all
Add-VBRCopyJob : Use File type to create FileCopy job
At line:1 char:1


I don't want to use the file parameter for this, since it will create a file copy job.
My guess is that I'm specifying the folder parameter wrong, but I don't know how to properly code it.
IonutN
Novice
 
Posts: 4
Liked: never
Joined: Thu Sep 25, 2014 8:57 am
Full Name: Ionut Nica

Re: Add-VBRCopyJob - how to properly specify target as datas

Veeam Logoby v.Eremin » Thu Jun 18, 2015 8:18 am

Try to disregard -folder parameter completely, as it makes commandlet believe that you're about to create file copy job.

Alternative way to create exact copy of VM might be restoring VM from a backup or replicating source VM.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 9 guests