Have you ever been facing your security department demanding you to change your ESX root password?
Well I did. At the current site there’s a strict security policy where passwords must change every 2 months. Offcourse as a good administrator I changed the ESX root account …. ehm …. well …. ehm …. never.
Because we have over 60 ESX hosts and I’m lazy I did some googling and found this thread on the VMTN forum.
I have some problems with the provided example:
- Password entry is not secure as it is in plain text.
- There is no error checking. If for some reason the connection to an ESX host fails the script just terminates.
- The security department responsible for changing the passwords doesn’t have access rights on our vCenter server. So they cannot login to vCenter to retrieve the ESX hosts from it.
- We have multiple vCenter servers
So I took the example and performed my first real powershell scripting magic on it. First I removed the connection to the vCenter server and replaced it by a textfile. This way the security department could retrieve all ESX hosts from the CMDB and put them in a simple textfile called ‘esxservers.txt’.
Next I’ve thrown in some security for entering passwords and a check to compare the new root password to avoid typos.
Here’s the result.
| # # This script changes the root password on all ESX hosts in the esxservers.txt textfile # # Add VI-toolkit # # Get new root credential # Compare passwords # Create new root account object # Get list of Host servers from textfile to change root password on |
Example esxservers.txt:
|
esx001.yourdomain.local esx002.yourdomain.local esx003.yourdomain.local esx004.yourdomain.local |
Download: esx_change_root_password.ps1
Feel free to use it or change it at your own risk.
Remember: I do not take any resposibillites for things that happen to your ESX servers due to using this script.
No related posts.

on Feb 17th, 2009 at 4:16 pm
Great Script, Arnim! And yes indeed, changing root-password is not something VI-admins like to do…
on Feb 18th, 2009 at 10:22 am
[...] I did a post on how to change your ESX root password using a Powershell script and told you that I, as a good administrator, didn’t change my [...]
on Jul 8th, 2009 at 7:00 am
[...] Another great script from Arnim van Lieshout. [...]
on Aug 3rd, 2009 at 9:16 pm
[...] Bulk ESX Password Change – VI Toolkit Aug.03, 2009 in Scripts http://www.van-lieshout.com/2009/02/bulk-change-your-esx-root-password/ [...]
on Jan 6th, 2010 at 10:50 am
[...] Bulk change your ESX root password [...]