I'm trying to do a get-view command that limits the results based on a subset of clusters. I can do this easily for VM objects but when I use the same type command for the view it does not work. Can someone suggest a working way to do this. Here is code that may better describe what I am doing:
\# Get VMs in subset of clusters ***this works
$Subset = "Cluster 2","Cluster 4","Cluster 6"
$VM = Get-Cluster $Subset | Get-VM | Sort Name
\# Get VM Views in subset of Clusters ***this does not work
$Subset = "Cluster 2","Cluster 4","Cluster 6"
$VMView = Get-Cluster $Subset | Get-View -ViewType VirtualMachine
Thanks in advance,
-Earl
Hi Earl,
The problem is that the Get-View cmdlet doesn't have the -Location parameter that is implicit used by the Get-VM cmdlet in the pipeline to filter on the clusters. You can change your code in the next way to get all the virtual machine views of the specified clusters:
$Subset = "Cluster2","Cluster 4","Cluster 6" $VMView = Get-Cluster $Subset | Get-VM | Get-View
Regards, Robert
Hi Earl,
The problem is that the Get-View cmdlet doesn't have the -Location parameter that is implicit used by the Get-VM cmdlet in the pipeline to filter on the clusters. You can change your code in the next way to get all the virtual machine views of the specified clusters:
$Subset = "Cluster2","Cluster 4","Cluster 6" $VMView = Get-Cluster $Subset | Get-VM | Get-View
Regards, Robert
(sorry. not sure what happened in the first post)
I'm trying to do a get-view command that limits the results based on a subset of clusters. I can do this easily for VM objects but when I use the same type command for the view it does not work. Can someone suggest a working way to do this. Here is code that may better describe what I am doing:
\# Get VMs in subset of clusters ***this works
$Subset = "Cluster 2","Cluster 4","Cluster 6"
$VM = Get-Cluster $Subset | Get-VM | Sort Name
\# Get VM Views in subset of Clusters ***this does not work
$Subset = "Cluster 2","Cluster 4","Cluster 6"
$VMView = Get-Cluster $Subset | Get-View -ViewType VirtualMachine
Thanks in advance,
-Earl
Hi Earl,
welcome to the VMware Communities.
If you are not happy with a post you can edit the post and change what you don't like.You don't have to make a new post ;-).
Did you see my post in between yours?
Regards, Robert
Thanks Robert!
Your answer worked.
Regarding the edit/reply... my first post in this comment did not/does not offer an "edit" link. That is why I re posted the question as a reply. oddly, my re posted reply does have an edit link.
Anyway, thank you again for your swift and correct answer.
-Earl
Of course, now I see the edit thread link on the right side under action. hehehe