VMware Cloud Community
xybal
Enthusiast
Enthusiast
Jump to solution

Poweroff / poweron VM via powerCLI script

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

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
Jump to solution

Hi,

Is thi powering off cleanly my VMs ?

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

Thx

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
xybal
Enthusiast
Enthusiast
Jump to solution

And finally is this shutdown my VMs properly ?

Thx very much

Reply
0 Kudos
xybal
Enthusiast
Enthusiast
Jump to solution

Can you give me the same to powerOn my VMs ?

Thx very much

Reply
0 Kudos
xybal
Enthusiast
Enthusiast
Jump to solution

I've found the answer :

Start-VM instead of shutdown-VMguest

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos