ganapa2000
Enthusiast
Enthusiast

change root password of all ESXi hosts in a cluster

Jump to solution

Hi,

I would like to change root password of all ESXi hosts in a cluster through CLI

Please help

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Try something like this

$user = 'root'

$pswd = 'VMware1!'

$newPswd = 'VMware2!'

$esxServers = Get-Cluster -Name MyCluster | Get-VMHost

foreach($esx in $esxServers){

    $srv = Connect-VIServer -Server $esx.Name -User $user -Password $pswd 4> $null

    if($srv){

        Set-VMHostAccount -UserAccount $user -Password $newPswd -Server $srv -Confirm:$false

        Disconnect-VIServer -Server $esx.Name -Confirm:$false

    }

    else{

        Write-Host "Logon failed $($esx.Name)"

    }

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

Try something like this

$user = 'root'

$pswd = 'VMware1!'

$newPswd = 'VMware2!'

$esxServers = Get-Cluster -Name MyCluster | Get-VMHost

foreach($esx in $esxServers){

    $srv = Connect-VIServer -Server $esx.Name -User $user -Password $pswd 4> $null

    if($srv){

        Set-VMHostAccount -UserAccount $user -Password $newPswd -Server $srv -Confirm:$false

        Disconnect-VIServer -Server $esx.Name -Confirm:$false

    }

    else{

        Write-Host "Logon failed $($esx.Name)"

    }

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Enthusiast
Enthusiast

Thanks a lot for your instant response....it worked Smiley Happy

0 Kudos