PowerCli: Reconnect Esxi host to vCenter

For instructions on how to connect to VMware PowerCLI, Follow the post here: 

Change the password from vmware12! to the root password used on the environment.


Get-VMHost -state Disconnected | foreach-object {
  $vmhost = $_
  $connectSpec = New-Object VMware.Vim.HostConnectSpec
  $connectSpec. force = $true
  $connectSpec. hostName = $vmhost.name
  $connectSpec. userName = 'root'
  $connectSpec. password = 'vmware12!'
  $vmhost. extensionData.ReconnectHost_Task( $connectSpec,$null )
}