Applies to VMware, PowerCLI, Virtual Machines
Modules needed: vmware.powercli
As someone who works in a VMware environment, and likes the command line, PowerCLI is a lifesaver. Are you mad about the phasing-out of vSphere, forcing everyone to use the web-based vCenter manager? PowerCLI is the best way to get around it. I’ve been doing my research making sure I can do everything in PowerShell that I can in vSphere/vCenter. One of the most common tasks being creating virtual machines.
Before we get started, there are a few things you are going to need. First of all, you need a vCenter host. Got it? Great. Next, you need the module PowerCLI. This can be easily installed by typing install-module vmware.powercli.
In my current environment, we are utilizing Templates, Customization Specifications, and Tags.
- Templates are pretty simple to make, since you can just convert a running VM to one. This is a good place to start.
- In a future post, I’ll explain how to create Customization Specs using PowerCLI as well. Currently, I’m using OS Customization specs to set the network adapters, and join the machine to the domain.
- Lastly, we use Tags to set when the VM will be backed up using Veeam.
Since there’s a good amount of code going into this, I’ve commented through the script to show you what’s happening. It goes like this: