Mike-S
Contributor
Contributor

PowerCLI & host name

Hello,

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?

Cheers

0 Kudos
2 Replies
DougBaer
VMware Employee
VMware Employee

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)

Good luck

Doug Baer, Staff Architect, Sr. Manager of vPod Architecture team for the VMware Hands-on Labs | VCDX #019, vExpert 2012-20 | @dobaer
0 Kudos
admin
Immortal
Immortal

(Moved to PowerCLI community)

You can get this with Get-VMHostNetwork.

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

0 Kudos