When the root password cannot be remembered the only way to reset it, is to re-install the ESXi host, except when the host is already part of a vCenter. Then you can leverage this connection in order to reset the password. Reaching the esxcli tool through vCenter to the ESXi makes this possible.
Here are the steps:
- Connect to vCenter using PowerCli
- Create an ESXCli object
$ESXCli = Get-ESXCli -V2 -VMHost <yourHostName>
- Create the Arguments needed to reset the password
$Arguments = $ESXCli.system.account.set.CreateArgs()
- Fill the necessary information
$Arguments.id = 'root'
$Arguments.password = "<yourPassword>"
$Arguments.passwordconfirmation = "<yourPassword>"
- Send the already filled information into the ESXi
$ESXCli.system.account.set.Invoke($Arguments)
Your password is changed.
Of course you can wrap the whole process into a function that can be used by other members of the team.
function Reset-ESXiRootPassword {
param($VMhost, $RootPassword)
$ESXCli = Get-ESXCli -V2 -VMHost $VMhost
$Arguments = $ESXCli.system.account.set.CreateArgs()
$Arguments.id = 'root'
$Arguments.password = $RootPassword
$Arguments.passwordconfirmation = $RootPassword
$ESXCli.system.account.set.Invoke($Arguments)
}
Packing the function into a module can be benifical. More info can be read here.
Leave a Reply