Angels Technology

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Friday, June 29, 2012

Power off Virtual machines via command line

Posted on 1:29 AM by Unknown
     Here are the steps to power down a vm via ssh or tech support mode.
    The reason this could be useful is if you are having problems with your management agents and before a reboot of the host you wanted to shutdown the vms

    Connect to the host in question. Im using ssh. Make sure you enabled it.


    First list all your vms on the host::      vim-cmd vmsvc/getallvms
    This will list every vm.



    It will list:
  1. Vmid   : virutal machine id
  2.  Name : of the server in vsphere
  3.  File :: which is the location and name of the VMX,
  4. Guest OS ::  os type
  5. Version :: of hardware     


  6. Example:
    For 250-DC01
  7. Vmid   : is 7
  8.  Name : is 250-DC01.
  9.  File :: located in datastore2 under 250-DC01
  10. Guest OS ::  win 2008 64 is listed as windows7server64guest
  11. Version :: of hardware    is 8


  12. The VMID is the key to the following steps.
    To get the power state of 250-DC01 we would enter

    vim-cmd vmsvc/power.getstate VMID

    Which in this case is

    vim-cmd vmsvc/power.getstate 7







    To gracefully to a shutdown, enter

    vim-cmd vmsvc/power.shutdown VMID

     which in this case is

    vim-cmd vmsvc/power.shutdown 7




    If you run the power.getstate again you will see its off now.



    If you have a vm where it either will not shutdown or you don’t have vmware tools installed, you will need to use another command.
    vim-cmd vmsvc/power.off VMID



     As you can see above, the VM with vmid 43 didn’t have vmwaretools so I was not able to send it a shutdown request.
    So I had to hard power down the vm.


    My suggestion, shutdown first, hard power down if you have to.




Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in command line, esxi, ssh, vm, vmware | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Copy and paste clipboard items to and from your vsphere virtual machines and your pc
    Wanted to copy and paste text between your pc and a vm? Now you can. Power off your VM. Go to the vm properties->Options->Advanced-...
  • Interesting look at Win cpu usage vs Vmware CPU usage
    I came across this scenario: The windows task manager shows the cpu of the vm pegged at 100%. The vmware performance monitor says that ...
  • Storage comparison
    One of Cormac Hogan s posts provides a good basis for compares of different storage types for vmware Vsphere and how they stack up. He dis...
  • E1000 vs e1000e in vmware : notes
    Performance difference " The performance should be about the same, the reason for the change is that Intel is not longer supporting the...
  • vCenter and Hosts Disconnected -- Reason: Cannot verify the SSL thumbprint
    Just saw this over on the forums, but if your hosts are getting this error: Cannot syncronize the host <hostname.fqdn>, Reason: Cannot...
  • Vmware DRS anti affinity rules wont let you enter maintenance mode for a esxi host
    You have a DRS rule that specifies that 2 vms need to be kept apart: In this case: 250-FT and 250sql3 For larger clusters with multiple...
  • Vmware esxi : Intel Pro/1000 ET quad port adapter and ISCSI
    I've seen issues pop up with intel quad ports here and there on the forums so I thought it would be good to note down what worked here...
  • Snapshot creation /reversion/ deletion/ listing with vim-cmd
    Here we are going to use the command line on a esxi host to create, revert, and delete snapshots. First ssh into your host. Important thi...
  • shutdown your esxi host using powercli
    if you want to shutdown a host using powercli: Set-VMhost -VMhost HOSTNAME -State Maintenance get-vmhost HOSTNAME | Foreach {Get-View $_.ID}...
  • Setting your esxi host to restart automatically after crash or purple screen aka psod
    The default and recommended setting is to leave the purple screen of death up to help you notice that het host has died and also leave t...

Categories

  • 5.1
  • backup
  • cloud
  • cluster
  • command line
  • console
  • converter
  • cpu
  • datacenter
  • datastore
  • datastore. rdm
  • DCUI
  • dell
  • disaster recovery
  • display
  • DR
  • e1000
  • e1000e
  • ec2
  • esx
  • esxi
  • esxtop
  • extent
  • Good for enterprise
  • HA
  • hcl
  • host
  • HP
  • ibm
  • iometer
  • iscsi
  • iso
  • linked mode
  • logs
  • MAC
  • memory
  • NFS
  • NIC
  • NTP
  • ova
  • ovf
  • p2v
  • pcie
  • performance
  • phone
  • powercli
  • powershell
  • PSOD
  • raid
  • RDM
  • resource pool
  • rvtools
  • scsi
  • sddc
  • snapshots
  • SQL
  • SRM
  • ssh
  • storage
  • svmotion
  • syslog collector
  • v2v
  • vapp
  • vcenter
  • vcloud
  • vcp
  • veeam
  • VI console
  • vm
  • vmdk
  • VMFS
  • vmkfstools
  • vmotion
  • VMUG
  • vmware
  • vmware tools
  • vmware.esxi
  • vmxnet3
  • vsphere
  • vum
  • web client
  • windows

Blog Archive

  • ►  2013 (28)
    • ►  October (2)
    • ►  September (1)
    • ►  August (1)
    • ►  July (1)
    • ►  June (14)
    • ►  May (1)
    • ►  April (1)
    • ►  March (5)
    • ►  February (1)
    • ►  January (1)
  • ▼  2012 (138)
    • ►  December (2)
    • ►  November (13)
    • ►  October (26)
    • ►  September (19)
    • ►  August (35)
    • ►  July (34)
    • ▼  June (9)
      • Shutdown all vms on a vsphere instance
      • Power off Virtual machines via command line: Part2...
      • Vmware reference card.
      • Power off Virtual machines via command line
      • Veeam one now has a free edition! Also try Veeam b...
      • ESXi host: viewing logs
      • snapshots, which order to delete
      • Troubleshooting: Vmotion: error migrating
      • Datastore: marked inactive but still accessible
Powered by Blogger.

About Me

Unknown
View my complete profile