Arnim van Lieshout Rotating Header Image

Reconnect ESX hosts using PowerShell

This week I ran into problems with vCenter server and almost all of my VMs were orphaned in vCenter. To resolve this issue I needed to disconnect/connect each ESX host. Because I hate doing repetitive tasks I created a little PowerShell script that I wanted to share with you.

# Variables
$VCServer = "vcserver.yourdomain.local"
$password = "rootPassword"

#Connect to vCenter Server
$VC = Connect-VIServer $VCServer

get-vmhost | % {
    $view = get-view $_.id
    $arg = new-object VMware.Vim.HostConnectSpec
    $arg.userName = "root"
    $arg.password = $password
    $arg.force = $true

    $view.DisconnectHost()
    $view.ReconnectHost($arg)
    }

Disconnect-VIServer -Confirm:$false

Ofcourse I got a little help from the VMware Community Here

Related posts:

  1. Bulk change your ESX root password 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...
  2. ESX console password aging Yesterday 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...
  3. Setting custom attributes with VMware PowerCLI Last week I wanted to extend my vCenter with some extra custom attributes on my VMs. This would extend the usability of the Export List feature for reporting purposes....
  4. New version of the Powershell Healthcheck script released Ivo Beerens published a new version of his Powershell Healthcheck script. Features: - VMware ESX server Hardware and version          - VMware vCenter version     - Cluster information (Updated)    ...
  5. Unable to login to your ESX server Ivo Beerens posted this article last week on the defunct cimservera processes that render an ESX Host unmanageable. See also this VMWare KB Article. Symptoms include: Unable to log...

0 Comments on “Reconnect ESX hosts using PowerShell”

Leave a Comment