1 Reply Latest reply on Jun 29, 2018 7:03 AM by LucD

    Refresh Connection State to vcenter after diconnect from ESXi Host

    feixfb Novice

      Hey there,

       

      what i try and what i do..

       

      I have a script which will configure some Settings of my ESXi Hosts from the vCenter view and also will create local ESXi User... for this task i connect to the ESXi Host directly..

       

      Soo..what i do ..

      ----

      1. Connect to my vcenter...

      2. Start my script...

      3. All Setting will be aplied to the first esxi host in the list...

      4. Connect to esxi

      Connect-VIServer $esx_Host.Name -User $rootpwd.User -Password $rootpwd.Password -wa 0

       

      create a user...

       

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

       

      5. The loop starts again.. and..

       

      Get-VMHost : 29.06.2018 15:30:31 Get-VMHost You are not currently connected to any servers. Please connect first using a Connect cmdlet.

       

      ----

       

       

      I try this on the cli ...

       

      Connect-VIServer <vcenter> (OK)

      Connect-VIServer <esxi host>  (OK>

      Disconnect-VIServer -Server <esxi Host> (Ok)

       

      Get-VMHost

      Get-VMHost : 29.06.2018 15:30:31 Get-VMHost You are not currently connected to any servers. Please connect first using a Connect cmdlet.

      In Zeile:1 Zeichen:1

      + Get-VMHost

      + ~~~~~~~~~~

          + CategoryInfo          : ResourceUnavailable: (:) [Get-VMHost], ViServerConnectionException

          + FullyQualifiedErrorId : Core_BaseCmdlet_NotConnectedError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVMHost

       

      Get-VMHost -Server <vcenter> (works)

      Name                 ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz   MemoryUsageGB   MemoryTotalGB Version

      ----                 --------------- ---------- ------ ----------- -----------   -------------   ------------- -------

       

      So the connection to the vcenter is still there.. is it possible to recover this connection as default connection?

       

      Greetz