xybal
Enthusiast
Enthusiast

Poweroff / poweron VM via powerCLI script

Jump to solution

Hi,

Is it possible to script a CLEAN poweroff for all my VM on a cluster (RedHat and Windows). Idem for poweron.

If YES, can you give me lines to put in the batch

Thx

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Yes, this initiates a shutdown through the guest OS.

For a cluster you could do

Get-Cluster -Name <your-clustername> | Get-VM | Shutdown-VMGuest -Confirm:$false

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
7 Replies
LucD
Leadership
Leadership

If you have the VMware Tools installed you can do

Get-VM | Shutdown-VMGuest -Confirm:$false

and

Get-VM | Start-VM -Confirm:$false

Note that the Shutdown-VMGuest cmdlet does not wait for the guest OS to complete the shutdown !

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

xybal
Enthusiast
Enthusiast

Hi,

Is thi powering off cleanly my VMs ?

And how can I apply this to all VMs from a specific cluster ?

Thx

0 Kudos
LucD
Leadership
Leadership

Yes, this initiates a shutdown through the guest OS.

For a cluster you could do

Get-Cluster -Name <your-clustername> | Get-VM | Shutdown-VMGuest -Confirm:$false

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
xybal
Enthusiast
Enthusiast

And finally is this shutdown my VMs properly ?

Thx very much

0 Kudos
xybal
Enthusiast
Enthusiast

Can you give me the same to powerOn my VMs ?

Thx very much

0 Kudos
xybal
Enthusiast
Enthusiast

I've found the answer :

Start-VM instead of shutdown-VMguest

0 Kudos
LucD
Leadership
Leadership

Yes, that was 2nd code block in my first reply.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos