PowerCLIGoodies / DRSRule

PowerShell module with support for managing vSphere DRS Rules and Groups
29 stars 9 forks source link

Remove VM from DRSVMGroup #2

Closed equelin closed 7 years ago

equelin commented 8 years ago

Hello,

First of all, thanks for your work on ths module ! I'm certainly missing something but I can't figure how to remove a VM from a DRSVMGroup. Could you tell me if it's possible or not ?

mtboren commented 8 years ago

Afternoon, Erwan-

Sure thing -- hope you have enjoyed it so far!

Yes, it is possible, though maybe (apparently) not the most obvious operation. When using the Set-DrsVMGroup cmdlet, the -VM parameter will either set the exact list of VMs that are a part of the group, or when used in conjunction with the -Append parameter, will append the given VMs to the list of existing VMs in the VMGroup object.

So, let's say that we have a VMGroup with VMs "vm0","vm1", and "vm2" in it. To remove "vm2" from the group, you could:

Get-DrsVMGroup myVMGroup0 | Set-DrsVMGroup -VM vm0,vm1

...which results in "myVMGroup0" having just the two VMs in it.

Or, if your VMGroup had , and you just wanted to remove one or two VMs without having to specify all of the VMs to "keep" in the group, you could do something like:

$oMyVMGroup = Get-DrsVMGroup myVMGroup0
$oMyVMGroup | Set-DrsVMGroup -VM ($oMyVMGroup.VM | ?{"vm221","vm337" -notcontains $_})

...which would effectively remove the VMs "vm221" and "vm337" from the VM group

How do either of these ways suit your needs?

And, there is definitely room for improvement for this kind of operation with the Set-DrsVMGroup cmdlet. We can add it to the enhancements to-do list, and I'll leave this Issue open until we come with some better ways for removing a VM from a VMGroup.

Cheers,

Matt

lucdekens commented 8 years ago

Matt, There is an issue when the user wants to remove all VMs from a VM group. That errors out. Am writing a fix. Luc

On Fri, Apr 22, 2016 at 9:52 PM, Matt Boren notifications@github.com wrote:

Afternoon, Erwan-

Sure thing -- hope you have enjoyed it so far!

Yes, it is possible, though maybe (apparently) not the most obvious operation. When using the Set-DrsVMGroup cmdlet, the -VM parameter will either set the exact list of VMs that are a part of the group, or when used in conjunction with the -Append parameter, will append the given VMs to the list of existing VMs in the VMGroup object.

So, let's say that we have a VMGroup with VMs "vm0","vm1", and "vm2" in it. To remove "vm2" from the group, you could:

Get-DrsVMGroup myVMGroup0 | Set-DrsVMGroup -VM vm0,vm1

...which results in "myVMGroup0" having just the two VMs in it.

Or, if your VMGroup had , and you just wanted to remove one or two VMs without having to specify all of the VMs to "keep" in the group, you could do something like:

$oMyVMGroup = Get-DrsVMGroup myVMGroup0 $oMyVMGroup | Set-DrsVMGroup -VM ($oMyVMGroup.VM | ?{"vm221","vm337" -notcontains $_})

...which would effectively remove the VMs "vm221" and "vm337" from the VM group

How do either of these ways suit your needs?

And, there is definitely room for improvement for this kind of operation with the Set-DrsVMGroup cmdlet. We can add it to the enhancements to-do list, and I'll leave this Issue open until we come with some better ways for removing a VM from a VMGroup.

Cheers,

Matt

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/PowerCLIGoodies/DRSRule/issues/2#issuecomment-213567486

equelin commented 8 years ago

Hello Matt,

Thank you for the reply. I see how to do it now.

I'm sure that users of your module will appreciate if you simplify how to use Set-DrsVMGroup !

One solution could be to move the original function to DRSRuleUtil.psm1 and build a new one based on the code you provide in your example. It certainly has other ways to solve that problem but that fix has the advantage to be easy to implement !

Anyway thanks again and feel free to ask if you need me to implement this solution or help finding another one.

Erwan

mtboren commented 7 years ago

Whew, a year+ later, and I finally made time to add this feature. Now to add the same functionality to Set-DrsVMHostGroup... (it will be less than a year for this next add)

mtboren commented 7 years ago

Alright, finally released a version that makes this more user-friendly (in release v1.2.0). Thanks for the suggestions, @equelin, and enjoy!