VMware Cloud Community
esxi1979
Expert
Expert
Jump to solution

esxi 6x passwd reset not working

Hello

below script worked well for my vcenter 5.1 & vcenter 5.5 based hosts.

Get-VMHost  -location xxx |sort  | where{$excludeServers -notcontains $_.Name.Split('.')[0]} | %{

  Connect-VIServer -Server $_.Name -User root -Password $currentPswd | Out-Null

  Write-host  "Connected to $_"

  Set-VMHostAccount -UserAccount root -Password $newPswd -Confirm:$false | Out-Null

  Write-host  "passwd change for root account on host  to $_"

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

  Write-host  "Disconnected from  $_"

}

But i got err in vcenter 6.x servers . passwd is not issue.

I got below err

Set-VMHostAccount : 6/19/2016 4:12:36 PMSet-VMHostAccount    At least one element in the source array could

not be cast down to the destination array type.

Any suggestions.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Can you try like this ?

Get-VMHost  -location xxx |sort  | where{$excludeServers -notcontains $_.Name.Split('.')[0]} | %{

  Connect-VIServer -Server $_.Name -User root -Password $currentPswd | Out-Null

  Write-host  "Connected to $_"

  Get-VMHostAccount -User root |

  Set-VMHostAccount -Password $newPswd -Confirm:$false | Out-Null

  Write-host  "passwd change for root account on host  to $_"

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

  Write-host  "Disconnected from  $_"

}

 


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

View solution in original post

0 Kudos
3 Replies
esxi1979
Expert
Expert
Jump to solution

i Also have below set

$multiState = (Get-PowerCLIConfiguration).DefaultVIServerMode

$warnings = (Get-PowerCLIConfiguration).DisplayDeprecationWarnings

Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false -DisplayDeprecationWarnings:$false | Out-Null

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you try like this ?

Get-VMHost  -location xxx |sort  | where{$excludeServers -notcontains $_.Name.Split('.')[0]} | %{

  Connect-VIServer -Server $_.Name -User root -Password $currentPswd | Out-Null

  Write-host  "Connected to $_"

  Get-VMHostAccount -User root |

  Set-VMHostAccount -Password $newPswd -Confirm:$false | Out-Null

  Write-host  "passwd change for root account on host  to $_"

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

  Write-host  "Disconnected from  $_"

}

 


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

0 Kudos
esxi1979
Expert
Expert
Jump to solution

Here is what i did finally tho

foreach ($line in $csv)

{

Connect-VIServer -Server $($line.esxi) -User "root" -Password $currentPswd -WarningAction silentlyContinue

Set-VMHostAccount -UserAccount root -Password $newPswd -Confirm:$false | Out-Null

Disconnect-VIServer -Server $($line.esxi) -Confirm:$false

}

0 Kudos