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.