Removing VM from a Job

PowerShell script exchange

Removing VM from a Job

Veeam Logoby Sethbartlett » Mon Jan 09, 2012 2:20 pm

So for some time we could not (or thought so) remove a VM from a job using the Remove-VBRObject and this is correct. It would just exclude the VM from the job, which isn't really removing the VM. I can't believe I didn't think of this earlier, by .Delete() works. So what we can do is the following:

v6
Code: Select all
$Job = Get-VBRJob -Name "My Job Name"
$Job.GetObjectsInJob()


v5
Code: Select all
$Job = Get-VBRJob | ?{$_.name -eq "My Job Name"}
$Job.GetObjectsInJob()


From here, this will give us a list of VMs in a job, we can then do:

Code: Select all
($Job.GetObjectsInJob() | ?{$_.name -eq "Name of VM").Delete()
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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 5 guests