Automation

 View Only
Expand all | Collapse all

get-vmhost | get-vm

  • 1.  get-vmhost | get-vm

    Posted Jan 08, 2009 03:27 PM

    The command "Get-VMhost -name ESXhost | Get-VM" return more VMs than that there on the VMware ESX host currently. Anybody seen this before?



  • 2.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 03:48 PM

    its probably returning all the VM on the host ( ESXHost) both powered on and powered off...



  • 3.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 04:34 PM

    Maybe it's the dreaded "VM creep" :smileyhappy:




    [PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

    Author of the upcoming book: Managing VMware Infrastructure with PowerShell

    Co-Host, PowerScripting Podcast (http://powerscripting.net)

    Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org



  • 4.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 06:44 PM

    is it showing your templates as well?



  • 5.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 06:50 PM

    No its one VMware ESX server of a cluster of 8 servers. I did a VMotion of all VMs except one on the VMware ESX server . Only one VM active and no powered off VMs or templates.



  • 6.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 06:59 PM

    what script are you using?

    are you specifying the esx-hostname?? if not, it might pull all of the vm's of the cluster/dc



  • 7.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 07:03 PM

    Yes i'am specifying the ESX hostname

    Get-VMhost -name ESXhostname | Get-VM"



  • 8.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 07:10 PM

    looks like from my testing its getting the entire cluster...

    try connecting directly to the host instead of vc and see if you see the same results



  • 9.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 07:19 PM

    connecting directly to the host works, but i want to make a script that all VMs on the specified ESX hosts get vmotioned with the move-vm command.



  • 10.  RE: get-vmhost | get-vm

    Posted Jan 08, 2009 07:33 PM

    See if this works:

    ( Get-VMHost foo | Get-View ).VM | foreach-object { $_ | Get-VIObjectByVIView }






    [PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

    Author of the upcoming book: Managing VMware Infrastructure with PowerShell

    Co-Host, PowerScripting Podcast (http://powerscripting.net)

    Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org



  • 11.  RE: get-vmhost | get-vm

    Posted Jan 09, 2009 11:30 AM

    figured it out, seems like a bug...

    try: Get-VM | Where-Object {$_.Host.Name -eq "esxhost"}



  • 12.  RE: get-vmhost | get-vm

    Posted Jan 09, 2009 02:43 PM

    $hostinfo = get-vmhost "vmhostname"

    $vmviews = (Get-View $hostinfo.ID).VM

    $vmviews | % {

    $_ | Get-VIOBjectByVIView

    }



  • 13.  RE: get-vmhost | get-vm

    Posted Jan 12, 2009 04:10 PM

    Hi,

    Could you please give some more details about the environment against which you are reproducing this issue. I've tried to reproduce it against a vc that has a couple of hosts inside a single cluster each containing several vms. When I execute Get-Vmhost -Name MyESX | Get-Vm everything seems to be OK and the result contains only the vms from MyESX.

    Which version of the toolkit (Get-VIToolkitVersion) are you using?

    10x in advance for the info!

    \Yavor