Hi people,
Please
Is possible to list all vms that are not part of drs rule group with Powercli?
You could do something like this
$clusterName = 'MyCluster'
$cluster = Get-view -ViewType ClusterComputeResource -Property Host,ConfigurationEx -Filter @{'Name'=$clustername}
$VmInGroup = $cluster.ConfigurationEx.Group | %{$_.VM | %{$_.Value}}
Get-View -Id $cluster.Host -Property VM | %{
if($_.VM){
Get-View -Id $_.VM -Property Name | where{$VmInGroup -notcontains $_.MoRef.Value} | select Name
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this
$clusterName = 'MyCluster'
$cluster = Get-view -ViewType ClusterComputeResource -Property Host,ConfigurationEx -Filter @{'Name'=$clustername}
$VmInGroup = $cluster.ConfigurationEx.Group | %{$_.VM | %{$_.Value}}
Get-View -Id $cluster.Host -Property VM | %{
if($_.VM){
Get-View -Id $_.VM -Property Name | where{$VmInGroup -notcontains $_.MoRef.Value} | select Name
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
Thanks your help.
Is possible to list all clusters in the virtual center?
$(get-cluster).name
You could just pump it into a foreach with Luc's script above.
Or leave out the Filter
Get-view -ViewType ClusterComputeResource -Property Host,ConfigurationEx | %{
$VmInGroup = $_.ConfigurationEx.Group | %{$_.VM | %{$_.Value}}
Get-View -Id $_.Host -Property VM | %{
if($_.VM){
Get-View -Id $_.VM -Property Name | where{$VmInGroup -notcontains $_.MoRef.Value} | select Name
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc
The error below appeared
Get-View : Cannot validate argument on parameter 'Id'. The argument is null or
empty. Provide an argument that is not null or empty, and then try the command
again.
+ Get-View -Id $cluster.Host -Property VM | %{
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Sorry, my bad.
The code above is corrected
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference