tag:blogger.com,1999:blog-3224609577145482350.post1362377875387083467..comments2024-03-27T19:19:38.323+05:30Comments on My vCloud Notes: vCenter | Snapshot OperationsGautam Joharhttp://www.blogger.com/profile/10890251936106071795noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3224609577145482350.post-55148315272648126522020-08-21T11:52:42.670+05:302020-08-21T11:52:42.670+05:30I hope that how to automatically create VMs from t...I hope that how to automatically create VMs from template after patching is not a question here because it is lot easier and you will find many articles on the web.<br /><br />I answered what I found that can be challenging to achieve. Rest,if you want to know more then don't hesitate to ask.Gautam Joharhttps://www.blogger.com/profile/10890251936106071795noreply@blogger.comtag:blogger.com,1999:blog-3224609577145482350.post-20905253119016089112020-08-21T11:48:13.477+05:302020-08-21T11:48:13.477+05:30Below is my idea to automate it. What I have given...Below is my idea to automate it. What I have given below is an idea which answer your question. You might face some challenges to understand it if you don't<br />know the powershell. In case, you face any issue or any further question then feel free to let me know.<br /><br />Considering lack of time, this is the best answer I have for your question. Probably, you will face some errors, if so then don't hesitate to share.<br /><br />Well, I think your meaning by plant is vcenter server. Always use generic terms rather than a organization specific.<br />it help to understand faster ;)<br /><br />So, question is, how to automatically patch a template?<br /><br />Direct patching of a template is not possible <br /><br />1) you need to first convert it into a VM.<br />2) Patch the VM<br />3) Convert it back into template<br /> <br />.............start her....................................<br />#Below command will convert the template into VM<br />Set-Template -Template Win2012-R2 -ToVM <br />#Below command will check and install the update inside GuestOS automatically and will reboot it as well<br />$VM = read-host "Enter the name of VM"<br />$User = read-host "Enter the username to login"<br />$pass = read-host "Enter the password to login"<br />$Chpass = @"<br />Get-WindowsUpdate -install -acceptall -autoreboot<br />"@<br />Invoke-VMScript -VM $VM -ScriptText $Chpass -GuestUser $user -GuestPassword $pass -ScriptType Powershell<br />#this behaviour need to explore that how switching from above to below command behave.You need to check this by your own as I don't have this setup to check this.<br />#I did mention sleep to overcome with any frequent changeover. You might need to increase the sleep time if patching take more than the mentioned seconds.<br />sleep(15)<br />#Below command will convert the VM back into template<br />Set-VM Win2012-R2 -ToTemplate -Confirm:$false<br />...............End here.....................................<br /><br />What's next-<br /><br />Copy above script, save into .ps1 file and put it into task scheduler and run as per your need.<br /><br /><br />Best Regards,<br />Team vCloudNotesGautam Joharhttps://www.blogger.com/profile/10890251936106071795noreply@blogger.comtag:blogger.com,1999:blog-3224609577145482350.post-29773494537417311082020-08-21T09:27:17.249+05:302020-08-21T09:27:17.249+05:30Hi Gautam Sir, In my environment, we are having 12...Hi Gautam Sir, In my environment, we are having 12 different different plant with different network and all are not connected with each other and while creating a VM from template we need to patch the template then create a VM so I want to know if there is any automation or script available to patch the templates on monthly basic automatically or on single single click it will MS patches will apply on templates.<br />Regards,<br />Ananta Nayak Patching of Templateshttps://www.blogger.com/profile/14384035579578727524noreply@blogger.com