Hi All
Is there a way to get the VMhost Group and All vm's in a VMHostGroup using Powercli?
Also, I would like to add multiple VM's to different VMhost Groups. Is it possible via POwercli?
Thank you all
Sunny
PowerShell shows only what it can on your console.
All the values should be there.
Try like this
select -ExpandProperty Member
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I assume you mean all VMs in a VMGroup?
Host are in a HostGroup.
But yes, with the Get-DrsClusterGroup cmdlet.
Get-DrsClusterGroup -Type VMGroup
And yes, with the Set-DrsClusterGroup cmdlet.
Set-DrsClusterGroup -VM NewVM -DrsClusterGroup MyGroup -Add
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
Thank you for a quick response. The powershell command you recommended gives me only half the information that i needed
Get-DrsClusterGroup -Type VMHostGroup -Name XXX-XX3
The above command give me all the ESX hosts that are part of the group.
Am trying to Retrieve all vm's part of the Drsvmhostrule and add more vm's to the rule. DRSVMhostrule and all the vm's in this+
that would be something like
Get-DrsVMHostRule -Type MustRunOn -name "VMs must run in XXX" | Get-VM
You are using -Type VMHostGroup, for the VM groups you need -Type VMGroup (like I showed in my previous reply).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD
i've changed the powercli command as per your suggestions.
For some reason all vm's that are part of the VMGroup are not displayed
Get-DrsClusterGroup -Type VMGroup -name "VMs for Sy" | select Member
Output as below
Member
------
{VM1, VM01, VM03, VMfr...}
I know i have more vm's in this list (close to 40 VM's)
PowerShell shows only what it can on your console.
All the values should be there.
Try like this
select -ExpandProperty Member
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Here's what I use to backup my DRS settings in all of our vCenters & Clusters. I would do a backup, edit the CSV file, and do a restore. I will past the restore script if you want it as well.
$vCenters = Get-Content "XXX.csv"
foreach ($vCenter in $vCenters)
{
Connect-VIServer $vCenter -WarningAction SilentlyContinue
$outpath = "XXX"
$outfile = $outpath + "Rules_" + $vCenter + ".csv"
$rules = Get-Cluster -server $vCenter | Get-DrsRule
$output=@()
if ($rules -ne $NULL)
{
foreach($rule in $rules){
$line=""|Select Cluster,Name,Enabled,KeepTogether,VM1,VM2
$line.cluster = (Get-View -Id $rule.ClusterId).Name
$line.name = $rule.Name
$line.Enabled = $rule.Enabled
$line.KeepTogether = $rule.KeepTogether
$line.VM1 = (get-view -id ($rule.VMIds)[0]).name
$line.VM2 = (get-view -id ($rule.VMIds)[1]).name
$output+=$line
}
}
$output | Export-CSV -notypeinformation $outfile
Disconnect-VIServer $vCenter -Confirm:$false
}
That doesn't include the groups that are not used in a rule.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd
Thanks for the reply.
Get-DrsClusterGroup -Type VMGroup -Name DrsGroup |
select -ExpandProperty Member
The above is what am after.
Hi Lucd
the Get-DRSClusterGroup gives all the vm's that are part of the group
I've just tried to add some vm's using Set-DRSclustergroup -Type VMgroup -Name XXXX -VM "XXXX" and it throws the error mesg
Set-DrsClusterGroup : A parameter cannot be found that matches parameter name 'Type'.
Whats is the best way to add vm's to a VMHost rule?
I've 2 Host rules
1) VM Must run in Sy1
2) VM Must run in Sy2
4 VM/Host Groups
1) SY1 Hosts
2) Sy2 Hosts
3) Sy1 vm's
2) Sy2 VM's
I would like to add vm's to different host rules. Whats the best way to achive this
Try like this
Set-DrsClusterGroup -VM vm1,vm2 -Add
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
@LucDthe commandlets Get/Set-DrsClusterGroup dosent seems to be working (return null values) in vSphere 7, any idea why? any alternate way for vSphere7 ?
There seem to be no VM nor VMHost groups in those rules.
Just tested, Get-DrsClusterGroup and Set-DrsClusterGroup work for me.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference