Is there a PowerCLI command to display which vCenter(s) you are connected to?
You are connected?
Display what is in $global:defaultviserver
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
One way is
([System.Uri]$global:defaultviserver.Client.Config.ServiceUrl).Host
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I get no output when I enter that command. No error or anything, just returns me back to C:\ prompt
You are connected?
Display what is in $global:defaultviserver
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes I am.
This command works!
$global:defaultviserver
And does this contain the Uri to the vCenter?
$global:defaultviserver.Client.Config.ServiceUrl
Btw, which PowerCLI version are you using?
Do a Get-PowerCLIVersion
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PowerCLI C:\> Get-PowerCLIVersion
PowerCLI Version
----------------
VMware PowerCLI 6.5 Release 1 build 4624819
---------------
Component Versions
---------------
VMware Cis Core PowerCLI Component 6.5 build 4624453
VMware VimAutomation Core PowerCLI Component 6.5 build 4624450
VMWare ImageBuilder PowerCLI Component 6.5 build 4561891
VMWare AutoDeploy PowerCLI Component 6.5 build 4561891
VMware Vds PowerCLI Component 6.5 build 4624695
VMware Cloud PowerCLI Component 6.5 build 4624821
VMware HA PowerCLI Component 6.0 build 4525225
VMware HorizonView PowerCLI Component 7.0.2 build 4596620
VMware Licensing PowerCLI Component 6.5 build 4624822
VMware PCloud PowerCLI Component 6.5 build 4624825
VMware Storage PowerCLI Component 6.5 build 4624820
VMware vROps PowerCLI Component 6.5 build 4624824
VMware vSphere Update Manager PowerCLI 6.5 build 4540462
And do you see the Uri of the vCenter?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is what I get
PowerCLI C:\>
PowerCLI C:\>
PowerCLI C:\> $global:defaultviserver.Client.Config.ServiceUrl
PowerCLI C:\>
Strange, and what about this variation?
([System.Uri]$global:defaultviserver.ServiceUri.AbsoluteUri).Host
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That works!
Is there a newer version of PowerCLI out? What are you running?
Since a couple of hours ago, there is PowerCLI 6.5.4.
But you will have to install it from the PowerShell Gallery with Install-Module, no MSI file anymore.
See Welcome PowerCLI to the PowerShell Gallery – Install Process Updates
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
$global
:DefaultVIServers.Count - run this in powercli while you are connected to multiple VC. this will show names
$global
:DefaultVIServers.Name - run this in powercli while you are connected to multiple VC. this will show names
@LucD This solution worked for me, making this first post to post this reply and just say man thanks for your work in these forums you are all over the place and almost always on point in the solutions you are providing us.
Thank you.
I just want to put both of the correct answers in one post.
A screenshot as an example: