Wednesday, February 10, 2021

VMware PowerCLI: Modify ESXi Hosts Primary and Secondary DNS Servers using Command line.

VMware ESXi DNS Server Configuration/Modification Using PowerCLI

We can easily change Primary and Secondary DNS Servers of all ESXi servers in a vCenter via below simple steps.

Steps:

1. Download and install VMware PowerCLI on any of the Windows machine in network. If there is a firewall between PowerCLI installed machine and vCenter, Port 443 should be allowed in firewall. In my case I installed PowerCLI in vCenter server itself.

PowerCLI Download URL

2. Launch PowerCLI by right click PowerCLI shortcut and choose "Run As administrator"

3. Execute below Command first to connect PowerCLI to vCenter Server.

Connect-VIserver 172.25.1.10 

        Note: Change vCenter IP with your actual vCenter IP



4. copy and paste below commands by editing DNS server IP with your actual DNS Server.


$dnsaddress = @()

$dnsaddress += "192.168.111.10"

$dnsaddress += "192.168.111.11"

Get-VMHost | Get-VMHostNetwork -ErrorAction SilentlyContinue | Set-VMHostNetwork -DnsAddress $dnsaddress


5. The command will print the output with the details of each ESXi hosts and its new DNS server.




No comments:

Post a Comment

Enter Comments...