<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Check vCenter Connectivity in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810930#M98232</link>
    <description>&lt;P&gt;I'm trying to connect to some vCenters via PowerCLi and I would like to be sure that there's no session already logged.&lt;/P&gt;&lt;P&gt;I'm using this script but it show me always the last vcenter connected twice&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$vCenterList = Get-Content ".\vCenterList.txt"&lt;/P&gt;&lt;P&gt;###Check if we are connected to vCenter Server(s)&lt;BR /&gt;foreach ($vCenter in $vCenterList){&lt;BR /&gt;if($global:DefaultVIServers.Count -gt 0){&lt;BR /&gt;# Return current connection&lt;BR /&gt;$global:DefaultVIServers[0]&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;# Finally, connect to the VMware vCenter&lt;BR /&gt;Connect-VIServer -Server $vCenterList&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;would you please assist me to correct the script in order to show to which vcenter(s) I'm already connected if not connected then it proceed with connectivity&lt;/P&gt;</description>
    <pubDate>Thu, 19 Nov 2020 11:56:03 GMT</pubDate>
    <dc:creator>SCharchouf</dc:creator>
    <dc:date>2020-11-19T11:56:03Z</dc:date>
    <item>
      <title>Check vCenter Connectivity</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810930#M98232</link>
      <description>&lt;P&gt;I'm trying to connect to some vCenters via PowerCLi and I would like to be sure that there's no session already logged.&lt;/P&gt;&lt;P&gt;I'm using this script but it show me always the last vcenter connected twice&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$vCenterList = Get-Content ".\vCenterList.txt"&lt;/P&gt;&lt;P&gt;###Check if we are connected to vCenter Server(s)&lt;BR /&gt;foreach ($vCenter in $vCenterList){&lt;BR /&gt;if($global:DefaultVIServers.Count -gt 0){&lt;BR /&gt;# Return current connection&lt;BR /&gt;$global:DefaultVIServers[0]&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;# Finally, connect to the VMware vCenter&lt;BR /&gt;Connect-VIServer -Server $vCenterList&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;would you please assist me to correct the script in order to show to which vcenter(s) I'm already connected if not connected then it proceed with connectivity&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 11:56:03 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810930#M98232</guid>
      <dc:creator>SCharchouf</dc:creator>
      <dc:date>2020-11-19T11:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Check vCenter Connectivity</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810936#M98234</link>
      <description>&lt;P&gt;What is in&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;$global:DefaultVIServers&lt;/STRONG&gt; before you start your script?&lt;BR /&gt;Perhaps do a &lt;STRONG&gt;Disconnect-VIServer -Server * -Confirm:$false&lt;/STRONG&gt; at the start of the script.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 12:05:47 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810936#M98234</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2020-11-19T12:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Check vCenter Connectivity</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810944#M98235</link>
      <description>&lt;P&gt;I have nothing in&amp;nbsp;&lt;STRONG&gt;$global:DefaultVIServers&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Disconnect-VIServer -Server * -Confirm:$false&lt;SPAN&gt;&amp;nbsp;at the start of the script.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I thought about doing it but it would be smarter to do it via the loop unless it is not possible&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 12:31:22 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810944#M98235</guid>
      <dc:creator>SCharchouf</dc:creator>
      <dc:date>2020-11-19T12:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Check vCenter Connectivity</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810945#M98236</link>
      <description>&lt;P&gt;Then I would do something like this&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;$vCenterList = Get-Content ".\vCenterList.txt"

foreach ($vCenter in $vCenterList){
    if($global:DefaultVIServers.Name -contains $vCenter){
        # Return existing connection
        $global:DefaultVIServers | where{$_.Name -eq $vCenter}
    }
    else
    {
        # Finally, connect to the VMware vCenter
        Connect-VIServer -Server $vCenterList
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 19 Nov 2020 12:36:28 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-vCenter-Connectivity/m-p/2810945#M98236</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2020-11-19T12:36:28Z</dc:date>
    </item>
  </channel>
</rss>

