I am in the process of upgrading my ESX 3.5 hosts to ESXi 4. I am creating a powershell script to automate the setup of the virtual switches , port groups, NTP etc. All is going well but I can not determine how to set the host name or Search Domains for the ESXi host using PowerCLI commands.
Can somebody please assist me?
I do not believe there is a cmdlet for this. You're talking about the NetworkSystem.
Connect-VIServer ESX_HOSTNAME $HS = Get-View -VIObject (Get-VMHost ESX_HOSTNAME) $NS = Get-View $HS.ConfigManager.NetworkSystem $NS.DnsConfig
You'll probably need to create a HostDnsConfig object and pass it to UpdateDnsConfig.
If that isn't enough to nudge you in the right direction, this may be:
$dnsconfig = $NS.NetworkConfig.DnsConfig # copy the existing values $dnsConfig.hostName = "MYHOSTNAME" $dnsConfig.domainName = "MYLAB.LOCAL" $dnsConfig.SearchDomain = ("MYDOMAIN.AZ.US","AZ.US") $NS.UpdateDnsConfig($dnsConfig)