PowerShell script exchange
Post Reply
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Removing VM from a Job

Post by Sethbartlett »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest