2 Replies Latest reply on Oct 7, 2016 10:20 AM by dazzpowder

    temperamental set-vmhostnetwork command

    dazzpowder Novice

      Hi All,

       

      I have an esxi postscript, all works but when setting the dns its hit and miss, no errors are thrown but the DNS entries don't appear on the esxi host causing the addition of syslog to fail as it cant resolve the hostname, if I run the same command or even the whole script again it will work, I've added a sleep entry after adding the host to  vcenter in case it was a timing thing.  Any ideas on what could be causing this or a way around the issue?   

       

      Add-VMHost -Name $esx -Location $cluster -User $credentials.UserName -Password $credentials.GetNetworkCredential().Password -RunAsync -force

      Write-Host -ForegroundColor GREEN "Adding ESXi host $esxi to vCenter"

      #

      sleep -s 10

      #

      #Set DNS

      Write-Host -ForegroundColor GREEN "Adding DNS Entries $dns1,$dns2 on vmHost $esxi"

      Get-VMHost $esx | Get-VMHostNetwork | Set-VMHostNetwork -DnsAddress $dns1,$dns2

      #