Closed equelin closed 7 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
$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
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
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
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)
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 ?