Showing posts with label VMWARE VSphere. Show all posts
Showing posts with label VMWARE VSphere. Show all posts

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

Wednesday, July 18, 2012

Powershell and VMware: "Get the list of all Virtual machines on VMware VSphere Server using PowerCLI.

 

HI,

In my first post about "Getting Started with VMware Vshpere PowerCLI" i already showed how to connect with VMware server.

Our today's task is simple. you get the list of all Virtual machines, and then we search for all "Powered ON" machines and after that all "Power off" machines.

Nothing complicated here. this is just a simple task and again the basic usage of Powershell is applies here. and we have some good "best friend " cmdlets those always with us. these cmdlets are "where-Object", "Select-Object".

Let's Start

Connect to your VMware server first using Connect-VIServer cmdlet. Once you successfully connected.

Run the Get-VM cmdlet.

That will show you the list of all Virtual machines including their "Power State"

18-07-2012 13-01-59 

If you want to see all the properties of Virtual Machines, run the below cmdlet.

Get-VM | Format-List *

Now you can see that we have detailed information about virtual machines.

18-07-2012 13-06-21 

And in case you want to know about a single Virtual Machine , use Get-Vm  and -Name of the machine and then Piped it to fl *

Get-Vm -Name "Dummy-Windows7" | fl * 

18-07-2012 13-18-05 

As i mentioned in the starting that our original target is to find the list of all Up and Running Virtual machines. To achieve that we can use Where-Object and show that Virtual machines whose status is equal to "Powered ON".

Get-vm | where { $_.PowerState -eq "PoweredOn"}

18-07-2012 13-20-08 

Finally i got he list of all "Power ON " server and  i am happy now :)

 

Thanks for reading.

Thanks!

Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin