VMware Cloud Community
eparedesl
Contributor
Contributor

Necesito crear una tarea programada para reiniciar varias vm a la ves, ademas de poder instalar vmware tools a varias vm.

Necesito crear una tarea programada para reiniciar varias vm a la ves, ademas de poder instalar vmware tools a varias vm.

16 Replies
LucD
Leadership
Leadership

Can the scheduled task run in the Windows Task scheduler?


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

Reply
0 Kudos
eparedesl
Contributor
Contributor

Si en windows si puedo, mi problema es como lo realizo con vmware?

Reply
0 Kudos
LucD
Leadership
Leadership

You can create a scheduled task on the vCenter as wel.

See my Scheduled Tasks – MethodAction post.


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

Reply
0 Kudos
eparedesl
Contributor
Contributor

El contenido del link, no contiene lo que necesito que es programar el reinicio de varias virtual machine a la ves, ademas de instalar vmware tools a varias vm a la ves.

Reply
0 Kudos
LucD
Leadership
Leadership

What type of vCenter are you using?

A VCSA or the Windows vCenter app?

With the VCSA it is impossible to schedule PowerCLI scripts, with the Windows-based vCenter you can trigger a PowerCLI script via a scheduled task.


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

Reply
0 Kudos
eparedesl
Contributor
Contributor

Esta es la versión

Reply
0 Kudos
LucD
Leadership
Leadership

That doesn't really tell me if you have the vCenter appliance (VCSA) or a vCenter installation on a Windows server


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

Reply
0 Kudos
eparedesl
Contributor
Contributor

vCenter appliance

Reply
0 Kudos
LucD
Leadership
Leadership

Then it becomes rather impossible to run scripts on the vCenter.
You could start a script on another server, but that would require another server.

In fact running the script from a Windows Task Scheduler or via a crontab on a Linux box, would be nearly the same.

Why do you absolutely want to run this through the vCenter Scheduled Tasks?


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

Reply
0 Kudos
eparedesl
Contributor
Contributor

La verdad es que si es a través de vcenter o no, no es importante.

Solo necesito instalar vmware tools en varias vm y reiniciar varias vm, lo ideal es que sea posible programarlo.

Reply
0 Kudos
LucD
Leadership
Leadership

Ok, in that case lets take this step by step.

First, does the following succeed in installing the VMware Tools on a VM?

Note that this assumes that your environment is configured to allow remote PSSessions.
In $Credentials you will need to provide the credentials for an account that is allowed to remote connect and install SW on the station.

$VM = "xx"

Get-vm $VM | Dismount-Tools

Get-vm $VM | Mount-Tools

$RMsession = New-PSSession -ComputerName $VM -Credential $Credentials

Invoke-Command -Session $RMSession -ScriptBlock {

   $CDRom = Get-WmiObject -class Win32_CDROMDrive | select Drive | ForEach {$_.Drive}

   $setExe = '\setup.exe'

   $arguments = '-s -v-qn ADDLOCAL=ALL REBOOT=R'

   $ExecuteEXE = Join-Path -Path $CDRom -ChildPath $setExe

   Start-Process -FilePath $executeEXE -ArgumentList $arguments

}


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

Reply
0 Kudos
eparedesl
Contributor
Contributor

Lo que necesito automatizar es lo siguiente:

tengo las siguientes vm:

vm a

vm b

vm c

vm d

a estas maquinas necesito instalar las vmware tools, a todas de una ves, sin hacerlo de manera individual, lo ideal es crear una tarea programada que lo haga a una cierta hora.

también tengo las siguientes vm:

vm e

vm f

vm g

vm h

estas maquinas necesito reiniciarlas todas de una ves, lo ideal es crear una tarea programada que lo haga a una cierta hora.

Reply
0 Kudos
cyberrodriguez
Contributor
Contributor

En vCenter haces click derecho en la Raiz del data center y vas a UpdateManager --> actualizacion de VMtools

alli tildas todas las VM que queres que actualizen automaticamente las vmtools cuando reinicia su ciclo de energia

Saludos

Reply
0 Kudos
eparedesl
Contributor
Contributor

La opción que me indicas es para actualizar vmtools no para instalar.

Reply
0 Kudos
cyberrodriguez
Contributor
Contributor

Crea un template con las vmtools instaladas, y creas las VM desde alli. solucionado

Reply
0 Kudos
cyberrodriguez
Contributor
Contributor

Para enviar comandos yo uso una vm linux que enviar comando por ssh vinculados por certificados asi no tenes que realizar el login manualmente

para reiniciar el comando es:

vim-cmd vmsvc/power.reboot (VMID)

Para buscar las VM a las que queres reiniciar tenes que busrcar el VMID con el siguiente comando:

vim-cmd vmsvc/getallvms

podes armarlo con cron-crontab

Saludos

Reply
0 Kudos