Hello,
I want to retreive a list of vm's in a virtual machine DRS group. I found the following oneliner but the output is empty. I am using Powercli 5.5 release 1 and vSphere 5.5 update1
(Get-Cluster CLUSTER).ExtensionData.ConfigurationEx.Group| ?{$_.vm} | %{" GROUP ${$_.name} found in this cluster"; foreach($CurrentVM in $_.vm) { (Get-View-id $CurrentVm).name } }
Need some help
No problem, we add an extra condition to the Where-clause
$clusterName = "MyCluster"
$vmGroupName = "VMgroup"
(Get-Cluster -Name $clusterName).ExtensionData.ConfigurationEx.Group |
Where {$_ -is [VMware.Vim.ClusterVmGroup] -and $_.Name -eq $vmGroupName} | %{
Get-View $_.VM | Select @{N="VMgroupVM";E={$_.Name}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you already try 5. Re: DRS Reporting
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello Luc,
Thank you for your answer. The script works. I'm now using the output of "VMgroupVM" as input for another script!
Many thanks,
Vincent
Hello Luc,
A last question. The output is formatted as follow:
VMgroupVM
"server1;server2;server3"
Is it possible to change the outut in the following format:
VMgroupVM
"server1"
"server2"
"server3"
Cheers,
Vincent
That is possible, but how would you like to display multiple VM groups on the cluster ?
Like this ?
VMgroup,VM
group1,VM1
group1,VM2
group1,VM3
group2,VM10
group2,VM11
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm only exporting VMgroupVM, so the vm names only are enough. I'm using the output as inputfile for logging vm's in one specific vm drs rulegroup.
Then you can do something like this
$clusterName = "MyCluster"
(Get-Cluster -Name $clusterName).ExtensionData.ConfigurationEx.Group |
Where {$_ -is [VMware.Vim.ClusterVmGroup]} | %{
Get-View $_.VM | Select @{N="VMgroupVM";E={$_.Name}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is what I need to export. I'm missing one thing. I need to define the specific VMgroup.
No problem, we add an extra condition to the Where-clause
$clusterName = "MyCluster"
$vmGroupName = "VMgroup"
(Get-Cluster -Name $clusterName).ExtensionData.ConfigurationEx.Group |
Where {$_ -is [VMware.Vim.ClusterVmGroup] -and $_.Name -eq $vmGroupName} | %{
Get-View $_.VM | Select @{N="VMgroupVM";E={$_.Name}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great work! Many many thanks!!! You earned a vBeer
Cheers Vincent
Is it possible to use PowerCLI to add vm's to a VM DRS group?
Not with a cmdlet I'm afraid.
But you can use the API, see for example Re: How to modify an existing Virtual Machine DRS -Group?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That's it! Thank you for the quick reply.