PowerShell script exchange
Post Reply
KRa
Lurker
Posts: 1
Liked: never
Joined: Jan 04, 2012 7:52 pm
Contact:

Excluding VMs under a Host

Post by KRa »

I'm trying to write a PowerShell script to exclude certain VMs from an existing backup job.
The problem I'm having is that the only object in the job list is a host, with all the VMs living underneath it.

Therefore, when I try to use:

Code: Select all

Remove-vbrJobObject -job $Job -Objects (Get-vbrJobObject -job $Job | Where {$_.Name -eq $VMName})
It does not see the VMs under the host, therefore I cannot parse them to return individual VMs using Get-VBRJobObject.

Is there a way to exclude the VMs under the host, without having to add each VM individually to the backup job?

Any help is greatly appreciated.
McClane
Expert
Posts: 106
Liked: 11 times
Joined: Jun 20, 2009 12:47 pm
Contact:

Re: Excluding VMs under a Host

Post by McClane »

I second that.
I would like to temporary exclude a single VM from a job, but the backup object list is a container usually.
Andreas Neufert
VP, Product Management
Posts: 7076
Liked: 1510 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Excluding VMs under a Host

Post by Andreas Neufert »

Not sure but give this a try. My lab isn´t available so I didn´t test this.
Remove-vbrJobObject -job $Job -Objects (Get-VBRJobObject -Name $VM)
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Excluding VMs under a Host

Post by ThomasMc »

After having a good play around trying for this to work, I've found that it's a bit messy;

1. Create a temp job
2. Add the VM to the new job
3. Pull the object id
4. Create CObjectInJob
5. Delete the temp job
6. Add the CObjectInJob to the exclusion list of the original

of course this is all done by powershell so fully automated, if your interested I can finish the script off.
Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests