VMware Cloud Community
gerf0727
Enthusiast
Enthusiast
Jump to solution

How to list vcenter hostname ?

Hello,

I do connect to a vcenter via connect-viserver and start querying information in different hosts and enventually send an email. But, I would like to output the vCenter hostname.

How do i output the vCenter hostname ?

Thanks for your help,

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
mattboren
Expert
Expert
Jump to solution

Hello, -

Assuming that you want the name of the last vCenter to which you connected, you can use the automatic global variable "DefaultVIServer" to get the name of the vCenter to which you are connected.  Access the "Name" property of this object, like:

$global:DefaultVIServer.Name

That do it?

View solution in original post

0 Kudos
1 Reply
mattboren
Expert
Expert
Jump to solution

Hello, -

Assuming that you want the name of the last vCenter to which you connected, you can use the automatic global variable "DefaultVIServer" to get the name of the vCenter to which you are connected.  Access the "Name" property of this object, like:

$global:DefaultVIServer.Name

That do it?

0 Kudos