Batch Changing ESXi Root Passwords
One of my customers wanted to reset the root password on all of their ESXi servers. This can be easily done through a Host Profile (which is particularly useful if you don’t know the root password), but that would require putting the hosts into maintenance mode and waiting for all of those vMotions to apply. There’s no need to put a host into maintenance mode just to change the root password, and so we looked for a better solution. Jeff found the PowerCLI cmdlet, set-vmhostaccount , and with that, we went to work. The script is actually really simple – it just connects to the ESXi host, then uses the set-vmhostaccount cmdlet to change the password, and records the change. For flexibility, I included a few variables as parameters. You may want to select only a subset of ESXi servers, and so there are both -hostSuffix and -hostPrefix parameters. If the hosts that you want to target are all called Sac-ESX#.lab.local and the production hosts that you’...