PowerShell script exchange
Post Reply
Posts: 2
Liked: 3 times
Joined: Mar 28, 2012 8:13 am
Full Name: Trevor Baker

Add Hyper-V VM's to a Backup Job

Post by tricksta123 »

I have been trying to add Hyper-V VM's to a backup job using the following script

Code: Select all

$VMName = "VM1"
$HyperVHostNAme = "HypV1"
$JobName = "Job1"

$HyperVHost = Get-VBRServer | Where-Object{$_.name -eq $HyperVHostNAme }
$Job = Get-VBRJob | Where-Object{$_.name -eq $JobName}
$HVEntity = Find-VBRHvEntity -Name $VMName

Add-VBRJobObject -Job $Job -Server $HyperVHost -Entities $HVEntity 

I get the message

Add-VBR-JobObject : Cannot bind parameter 'Entities'. Cannot convert the "Veeam.Backup.Core.Infrastructure.CHvVmItem" value of type "Veeam.Backup.Core.Infrastructure.CHvVmItem" to type "Veeam.Backup.ViSoap.Entity"

I have also tried the Add-VBRJobObject command with the -Objects variable instead of -Entities. This looks as though it works and gives no error but does not add the vm to the job.

I can only assume that this is because this cmdlet is wrappered for VMWare and not hyper-v. I cannot see a cmdlet in the guide for adding hyper-v vm's to hyper-v jobs. Does anyone know how?

Support Ref: [ID#5212550]

Posts: 293
Liked: 18 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Add Hyper-V VM's to a Backup Job

Post by ThomasMc » 1 person likes this post

While I can't test this on Hyper-V this is what you should be looking for

Code: Select all

$VMName = "dc01.vPowerCLI.local"
$ViHostName = "vc01.vPowerCLI.local"
$JobName = "VC Backup"

$ViHost = Get-VBRServer -Name $ViHostName
$Job = Get-VBRJob -Name $JobName
$JobObject = $ViHost | Find-VBRObject -Name $VMName

Add-VBRJobObject -Job $Job -Server $ViHost -Objects $JobObject 

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests