1

I'm trying to get and set the FQDN as the hostname for ESXi hosts in vCenter.

I have the following command :

$esxcli = Get-esxcli -vmhost 192.168.2.21
$getname = $esxcli.system.hostname.get() | select Fullyqualifieddomainname

Now when I check the variable value of $getname it has a value that I cannot set as the hostname which is :

write-host $getname
@{FullyQualifiedDomainName=esxi1.v.lab}

I tried using -replace that did not work.

$getname =  $getname -replace '[@{FullyqualifiedDomainName=}]',''
write-host $getname
sx1.v.b

Is there an alternate way to this.

Currently the ESXi hosts appear with their IP addresses as their display names in vCenter.

ESXI appear with IP addresses as names in vCenter

Huud Rych
  • 21
  • 5

1 Answers1

0

This has been resolved.

Since the value returned by $getname is in Hash table the key value is retrieved by using the command $getname.FullyQualifiedDomainName

Huud Rych
  • 21
  • 5