For those of us still relatively new to PowerCLI and working towards automating as many robotic tasks as possible, there is a handy tool in vCenter called Code Capture. This has been available since vCenter Server Appliance (VCSA) 6.7U2 in the developer centre so its not exactly new but a lot of people don’t realise its there.
This tool pretty much does as the name implies, it lets you complete an action in the VCSA GUI such as creating a VM and then gives you all the code required to complete that task. You can then modify and reuse that code to make running common tasks a lot faster in future.
Here is how you do it:
Enable Code Capture in your VCSA
Click “Start” or “Clear and start another”, Once its running you have a little flashing icon on the top right
Complete whatever action it is you want to capture the code for e.g. Create a new VM from a template or deploying a new Distributed Switch.
Once you have completed, click the record icon on the top right
You can then see all the code required to do this in future, you have the option to just copy it or download it
Its really as simple as that!
998 total views, 5 views today