ESXi 5.5 network configuration with PowerCLI

One nasty thing we need to do from time to time is ESXi initial configuration with it’s vswitches, dns, domain, searchdomains, ntp, portgroups, nics and many, many other things…

If you possess Enterprise Plus licences you are lucky enough to do all the things using Host Profiles. But in case if you don’t have any Plus licenses… you are on your own. But luckily for us, there’s PowerCLI. In the script below I’ll show you how to configure your ESXi hostname, domain, DNS servers, NTP server & service, search domains, vSwitch with it’s portgroups and vlan IDs.

*NOTE that this can only work from the point where your ESXi host is already added to vCenter.

Lines 5-10 should contain valid information about your infrastructure. Keep in mind that $vmhost variable has to be exact target hostname from your vCenter inventory.

Line 15, $phNic_vlans should be filled up with vmnic adapters that you want to use for your new vSwitch.

Lines 20-21 should be corrected with proper VLAN IDs.

As soon as lines mentioned above are correct, you can run the script and see how quickly your host can be configured with so many things 😉 Of course this example has to be customized to fit each environment, but I think it already gave you an idea of how to automate this part of ESXi configuration.

Leave a Reply