VMware Cloud Community
ivanunnio
Enthusiast
Enthusiast
Jump to solution

How to Export one list of more vCenter and DNS for farm.

Hi all

I have a small question, I have two lines of code that must recover the ESXi server DNS and Virtual Center.

How can I join?

Get-VMHost | Get-VMHostNetwork | Select Hostname, DNSAddress | Select Hostname, DNSAddress

Get-VMHost | Select-Object Name, @{N='vCenter';E={$_.Uid.Split('@') [1].Split(':')[0]}

Thanks so much.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

One way of doing this

Get-VMHost | Select Name,

    @{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},

    @{N='Hostname';E={$script:net = Get-VMHostNetwork -VMHost $_; $script:net.hostname}},

    @{N='DNSAddress';E={$script:net.DNSAddress -join '|'}}


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

One way of doing this

Get-VMHost | Select Name,

    @{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},

    @{N='Hostname';E={$script:net = Get-VMHostNetwork -VMHost $_; $script:net.hostname}},

    @{N='DNSAddress';E={$script:net.DNSAddress -join '|'}}


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

Reply
0 Kudos
ivanunnio
Enthusiast
Enthusiast
Jump to solution

Thank you so much for your support, but I have one more question. How can I put before the VC and then other Host ?
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You mean like this?

Get-VMHost | Select @{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},

    Name,

    @{N='Hostname';E={$script:net = Get-VMHostNetwork -VMHost $_; $script:net.hostname}},

    @{N='DNSAddress';E={$script:net.DNSAddress -join '|'}}

 


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