VMware Cloud Community
kevinjj
Contributor
Contributor

possible to get DNS info for VMhost?

looks like my script doesn't work.

Get-VMHost |Get-View |Select Name, @{N="DSN servers";E={(Get-View -Id

$_.configManager.networkSystem).networkConfig.dnsConfig.address}}

Tags (1)
0 Kudos
17 Replies
LucD
Leadership
Leadership

If you're using PowerCLI 4.x you can do

Get-VMHost | ` 
Select
Name, @{N="DSN servers";E={(Get-View $_.Extensiondata.configManager.networkSystem).networkConfig.dnsConfig.address}}


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

kevinjj
Contributor
Contributor

only get DNS info for some of the servers (ESX 3.0)... the rest of them are running ESX 3.5.

I also tried using "Get-VMHostNetwork". The error msg was "Get-VMHostNetwork        Object reference not set to an instance of an object."

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

Select Hostname,  DNSAddress

0 Kudos
LucD
Leadership
Leadership

Sorry, don't have any ESX 3.x left to test against.

Isn't just

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

enough to see the DNS IP addresses ?


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

0 Kudos
kevinjj
Contributor
Contributor

returned same error ""Get-VMHostNetwork        Object reference not set to an instance of an object."

0 Kudos
LucD
Leadership
Leadership

Which version of PowerCLI are you using ?

Get-PowerCLIVersion

And which ESX 3.5 version ?

Perhaps check if the ESX version is supported in the Release Notes.


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

kevinjj
Contributor
Contributor

VMware ESX Server 3.5 Update 5 Build 207095. Powercli version is 4.1 U1 build 332441.

0 Kudos
LucD
Leadership
Leadership

Strange, ESX 3.5U5 is supported.

Perhaps someone with an ESX 3.5U5 running can do the same test ?


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

0 Kudos
allencrawford
Enthusiast
Enthusiast

I don't have any 3.5 U5 hosts in the environment, but I do still have some older 3.5 U4 hosts.  Every single one of these scripts works on those hosts for me.  Not sure what is going on with your environment, but for what it is worth, here's another option to try that should be a little quicker (if it works):

Get-View -ViewType HostSystem -Property Config.Network.DnsConfig.Address,Name | Select-Object Name, @{N="DNS Servers";E={$_.Config.Network.DnsConfig.Address}}

0 Kudos
kevinjj
Contributor
Contributor

This script is much faster. However, it returns same results only showing DNS servers for ESX 3.0.2. The strange thing is that it doesn't work on any version of ESX 3.5. Is it because vCenter version is too old?

0 Kudos
allencrawford
Enthusiast
Enthusiast

What version of vCenter are you using?  Have you tried connecting directly to one of the ESX 3.5 U5 hosts to see if that makes a difference?

0 Kudos
kevinjj
Contributor
Contributor

vCenter v2.5. I tried connecting to single VMhost (ESX 3.5) , doesn't make sense....still returned nothing, no error msg.

0 Kudos
bulletprooffool
Champion
Champion

deleted

One day I will virtualise myself . . .
0 Kudos
allencrawford
Enthusiast
Enthusiast

He's trying to get the DNS server information from his ESX hosts, not his VMs.

0 Kudos
RvdNieuwendijk
Leadership
Leadership

I have no problems with all the scripts on this thread running against ESX 3.5U5 servers. Everything works fine for me. Connected to a vCenter 4.1 Server or directly connected to an ESX 3.5U5 server.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
kevinjj
Contributor
Contributor

The problem is with vCenter. It's unable to show DNS servers for those VMhosts using VI client. I have tried connecting from different workstations.

0 Kudos
allencrawford
Enthusiast
Enthusiast

Here's the million dollar question then.  Are you sure you've got DNS servers configured on these hosts?  If it isn't showing up in PowerCLI or the VI Client...

0 Kudos
kevinjj
Contributor
Contributor

configured name servers in /etc/resolv.conf

0 Kudos