PowerShell script exchange
Post Reply
Dziugas
Novice
Posts: 4
Liked: never
Joined: Nov 27, 2012 8:56 am
Full Name: Dziugas
Contact:

Add Hyper-V VM to existing backup job

Post by Dziugas »

Hi,

Is it possible to add hyper-v VM to a existing backup job via PowerShell?
I found many examples how to add VMWare VM to existing job but I can't find any example how to add hyper-v VM to backup job. Is it supported?

BR,
Dziugas
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add Hyper-V VM to existing backup job

Post by veremin »

Hi.

Can I ask you to provide a little bit more information regarding your task.
I'm wondering whether you're willing to add Hyper-V VM to the job within which VMware VMs are being backuped? Or just to add another Hyper-V VM to Hyper-V backup job?

Thanks.
Dziugas
Novice
Posts: 4
Liked: never
Joined: Nov 27, 2012 8:56 am
Full Name: Dziugas
Contact:

Re: Add Hyper-V VM to existing backup job

Post by Dziugas »

Hi,

I want to add additional Hyper-V VM to a existing Hyper-V backup job.

BR,
Dziugas
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add Hyper-V VM to existing backup job

Post by veremin »

As you may have already understood, the reason for my question was the fact that you can’t actually mix up Hyper-V and VMware VMs within one job.

As for your task, I believe, that something like this should work fine, though I didn’t have a chance to test it.

Code: Select all

asnp VeeamPSSnapin
$JobName = Get-VbrJob |? {$_.Name -eq "Name of your Job"}
$HVServer = Get-VbrServer |? {$_.Name -eq "Name of your Hyper-V Server"}
$VMtoAdd = $HVServer | Find-VBRObject |? {$_.Name -eq "Name of VM you want to add"}
Add-VBRJobObject -job $JobName -server $HVServer -Objects $VMtoAdd 
Thanks.
Dziugas
Novice
Posts: 4
Liked: never
Joined: Nov 27, 2012 8:56 am
Full Name: Dziugas
Contact:

Re: Add Hyper-V VM to existing backup job

Post by Dziugas »

Hi,

The output of commands looks like that:

Code: Select all

PS C:\Users\Dziugas> $JobName = Get-VbrJob |? {$_.Name -eq "LAB-v2"}
PS C:\Users\Dziugas> $HVServer = Get-VbrServer |? {$_.Name -eq  "CLUSTER.lab.local"}
PS C:\Users\Dziugas> $VMtoAdd = $HVServer | Find-VBRObject |? {$_.Name -eq "T001-229"}
Find-VBRObject : Failed to login to "SCVMM.lab.local" by SOAP, port 443, user "", proxy srv: port:0
At line:1 char:38
+ $VMtoAdd = $HVServer | Find-VBRObject <<<<  |? {$_.Name -eq "T001-229"}
    + CategoryInfo          : InvalidOperation: (Veeam.Backup.Po...d.FindVBRObject:FindVBRObject) [Find-VBRObject], Ex
   ception
    + FullyQualifiedErrorId : Backup,Veeam.Backup.PowerShell.Command.FindVBRObject
Veeam tries to connect to Virtual machine manager like to the ESX(i) host, via TCP 443 port.

In Veeam Backup & Replication PowerShell 6.5 reference guide I found only ESX(i) host mentioned as a "-server" parameter for Find-VBRObject command
This cmdlet returns a list of all VMs and VM containers on the specified ESX(i) host.

Is Find-VBRObject suitable for getting VM objects from Hyper-V servers?

BR,
Dziugas
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add Hyper-V VM to existing backup job

Post by veremin »

If such error occurred in vCenter case, I would say that it must have been caused by lack of memory available to PS-script and would definitely implement something like this:

Code: Select all

set-item wsman:localhost\Shell\MaxMemoryPerShellMB 512
However, since it’s completely opposite situation and since I’ve tried this script in my environment and ended up with the same or relatively the same error, it’s more likely to be typical limitation of support.

In fact, not only did I try “Find-VBRObject” method to address the issue but also I tested “Find-HvEntity”, still without any success.

So, on the surface it seems to be a restriction, but someone might correct me and provide a solution, that I’ve overlooked.

Thanks.
Dziugas
Novice
Posts: 4
Liked: never
Joined: Nov 27, 2012 8:56 am
Full Name: Dziugas
Contact:

Re: Add Hyper-V VM to existing backup job

Post by Dziugas »

Hi,

Find-VBRHvEntity works, but I can't use the object neither as "-object" nor as "-entity" in a command Add-VBRJobObject.

BR,
Dziugas
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add Hyper-V VM to existing backup job

Post by veremin »

Yep, that's exactly what I was talking about. By the means of "Find-HvEntity" you're able to receive information regarding VM residing on Hyper-V host, meanwhile you aren't able to do something useful with it, e.g. to provide this data either as "-object" or "-entity" parameter.

If I have time, I'll try to look at this issue again, more thoughtfully this time, and will report if some workaround comes into my mind.

Thanks.
BGilbert
Influencer
Posts: 14
Liked: 3 times
Joined: Jun 20, 2012 10:01 pm
Full Name: Brian Gilbert
Contact:

Re: Add Hyper-V VM to existing backup job

Post by BGilbert »

I know adding a Hyper-V VM to an existing Hyper-V job wasn't supported in version 6.0. I was hoping that got fixed in version 6.5.
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Add Hyper-V VM to existing backup job

Post by Sethbartlett »

@Dziugas I believe I sent BGilbert an unsupported script to do this, but there is not a cmdlet for it currently.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
BGilbert
Influencer
Posts: 14
Liked: 3 times
Joined: Jun 20, 2012 10:01 pm
Full Name: Brian Gilbert
Contact:

Re: Add Hyper-V VM to existing backup job

Post by BGilbert »

@Seth, the script broke when I upgraded to 6.5.
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests