VMware Cloud Community
Glenn88
Contributor
Contributor

script that starts a vm - server up

Hello,

I will make a bat script that call a powercli script up.

This powercli must check that the server is up or down when the server is down he must start the server.

When the sever is up the bat scrip must run further.

After the bat file has run succesful the server must be going down.

(the bat file coppy some directories from a other server to the template)

Can somebody help me with writing this script ?

I've try this but it didn't work

  1. Connect to every vSphere host in the cluster that contains vCenter

Connect-VIServer -Server 192.168.163.186 -Protocol https -User xxx -Password xxx

  1. Start vCenter

Get-VM -name DA-WWWT | Start-VM

0 Kudos
3 Replies
LucD
Leadership
Leadership

What exactly didn't work with the lines you included at the end of your post ?

The connection to the ESX(i) server or starting the vCenter guest ?

When your connected, does Get-VM return anything ?

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
Glenn88
Contributor
Contributor

The lines work when I put them in the command prompt.

But if I try to this with a script its failed

Maybe you can say me how you call the script up from a bat-file.

0 Kudos
LucD
Leadership
Leadership

Have a look at Alan's post Running a PowerCLI Scheduled task.

In that post you will see how to run a PowerShell script from a DOS CMD line or a BAT file.

____________

Blog: LucD notes

Twitter: lucd22


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