Do you have anymore specifics?
Schedule? How, where?
Clone? From an existing VM?
What do you already have?
And where did you get stuck?
Well I have a cluster in vCenter and I want to clone an existing Linux VM.
Cloning, for example, a Master VM every 3 days but I do not know how to clone on certain dates and the previous ones are eliminated
But where do you intend to run the schedule?
In the vCenter Scheduler or on a Windows box with the Windows Task Scheduler or on a Linux box with a crontab?
Are you looking for something like this?
New-VM -Name $NewVMName -VM $SourceVM -VMHost $TargetESXiHost -Datastore $TargetDatastore -RunAsync
I have the following initial script:
Where you connect to vCenter, clone the machine, disconnect the network adapter from the source VM, and then start the cloned VM.
Now what stuck me is that I'm not sure how to do so that cloning is generated every week but does not eliminate the already cloned machine that is generated as a new clone
$Hostesxi = "172.16.1.51"
$VMsource = "Ubuntu"
$VMclone = "Ubuntu-clone"
##Connect to vCenter
connect-viserver -server $vcenter_server -User $vcenter_user -Password $vcenter_pwd
##Clone VM, disco virtual tipo thick y carpeta de almacenaiento de la VM
New-VM -VM $VMsource -Name $VMclone -VMHost $Hostesxi -DiskStorageFormat Thick -Location "Laboratorios" -Notes "Clone creado $dateofclone by Marco Lopez"
##Desconect Network Adapter source VM
Get-VM $VMsource | Get-NetworkAdapter | Set-NetworkAdapter -connected:$false -startconnected:$false
##Iniciar VM clonada
GET-VM -Name $VMclone| Start-VM -Confirm:$False
The cloning process is not the big deal (see for example Re: Guide for the script need to take clone on every day per schedule time ), but you would first have to decide how you want to do the scheduling.
This has some impact on how the cloning and removal can be done.
When you use the vCenter scheduler, the cloning can be builtin.
when you use the Windows Task scheduler, you can run the PowerCLI script from a Windows box.
If you can confirm the script to work manually, I'd setup a scheduled task to run that file based on your Timeline.
I helped a lot that refedence practically the part of the cloning I have solved.
Now if you can guide me in the following:
The cloning was done from a source VM, what I need to do is how do I do that when the source VM does not have a connection, basically I do not fear ping for example to 172.16.6.90 that the ip in my source VM disconnect the network adapter from that VM and then turn on the last clone of said VM
If you want to delete the VM in $sourceVM, you can just do a Remove-VM.
Get-VM -Name $sourceVM | Remove-VM -DeletePermanently -Confirm:$false
Or do you mean something else?
I express myself badly apparently
I understand that it would be another Script, where I do a connection check to a VM if I do not have a connection to that VM that turns on another VM
I'm afraid you lost me.