There was some confusion on how to specify multiple dns server ip address or domain search names with the Set-VMHostNetwork cmdlet. Turns out is a simple comma separated list that get treated as a parameter array. Here is an example.

Connect-viserver vCenterServerFQDNorIP
$ESXiHosts  = Get-VMHost
foreach ($esx in $ESXiHosts) {
     Get-VMHostNetwork | Set-VmHostNetwork -DomainName  eng.example.com -DnsAddress dnsAddress1,dnsAddress2
}

Or in one-line

Get-VMHost | Get-VMHostNetwork | Set-VmHostNetwork -DomainName  eng.example.com -DnsAddress dnsAddress1,dnsAddress2

One response to “Change/Update DNS or domain with vSphere PowerCLI”

  1. ajkbond Avatar
    ajkbond

    please update to Get-VMHostNetwork -VMHost $ESXiHosts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.