VMware Cloud Community
feixfb
Contributor
Contributor
Jump to solution

Refresh Connection State to vcenter after diconnect from ESXi Host

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

What is the DefaultVIServerMode in your PowerCLI COnfiguration?

Do a Get-PowerCLIConfiguration, it should say Multiple, if not, change it with Set-PowerCLIConfiguration


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

View solution in original post

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

What is the DefaultVIServerMode in your PowerCLI COnfiguration?

Do a Get-PowerCLIConfiguration, it should say Multiple, if not, change it with Set-PowerCLIConfiguration


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

Reply
0 Kudos