Wednesday, July 25, 2012

Powershell & VMware: "Stopping" running Virtual Machines on VMware server using PowerCLI.

 

Hi,

The one of the main task as a administrator we do is shutting down and powering on the machines :) . Let see how we can stop/shutdown virtual machines using PowerCLI.

Let's Start.

Connected to your VMware VSphere Server first using PowerCLI. ( http://newdelhipowershellusergroup.blogspot.in/2012/07/powershell-vmware-getting-started-with.html )

use Get-VM cmdlet to list all Virtual Machine

25-07-2012 11-40-52

I want to stop/shutdown the virtual machine whose name is "Mrtg-Linux" and you can see the current state of the Virtual machine is "PoweredOn"

we can use Stop-VM cmdlet to stop  virtual machines.  in -VM provide the name of the Virtual machine and it ask you for confirmation type Y and press enter.

Stop-VM -VM Mrtg-Linux

Once you run this cmdlet

25-07-2012 11-59-50

and In case you face RED RED error and not able to STOP Virtual machine :) then use -KiLL Parameter

25-07-2012 12-30-54

Stop-VM -VM Mrtg-Linux  -kill

25-07-2012 12-33-34

Ok, and ok i know , i know you want to suppress the Confirmation isnt ? GEEK

to suppress the confirmation dialogue use -Confirm:$false

Stop-VM -VM Mrtg-Linux  -kill -Confirm:$false

25-07-2012 12-37-06

All Done, Happy :) ?

Thanks for reading.

Thanks!

Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin

00403skh

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Thank you for a great article,

    I think using Shutdown-VMGuest cmdlet is more useful because Stop-VM cmdlet forces a VM to power off, without trying to shutdown guest OS gracefully.

    ReplyDelete
    Replies
    1. Hi Ho-Sung,

      Thanks for liking and thanks for the feedback :) , and yes it is true that we can use use "Shutdown-VMGuest" to shutdown the VM gracefully , i don't know that never works :) for me somehow .. but will give it a try.

      Thanks
      Aman

      Delete