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
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0
with attribution required.
rev 2019.11.22.35464