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
Code: Select all
Add-VBRCopyJob : Use File type to create FileCopy job
At line:1 char:1
My guess is that I'm specifying the folder parameter wrong, but I don't know how to properly code it.