I'm try to set a fixed name and IP for my vm using powerCLI and VMware.Vim.CustomizationLinuxPrep. It is successfully setting both, however, it is also removing the "localhost" entry from my hosts file for 127.0.0.1, which is causing issues with my app which requires it.
Is there a way to force it to either not remove the localhost entry from the hosts file, or to write it back into it?
Here's my code:
$app_hostname = "myhostname"
$app_domain = "usa.blah.com"
$vmcustomize_os= New-Object VMware.Vim.CustomizationSpec
## Identity for Linux
$vmcustomize_os.identity= New-Object VMware.Vim.CustomizationLinuxPrep
$vmcustomize_os.identity.hostname= New-Object VMware.Vim.CustomizationFixedName
$vmcustomize_os.identity.hostname.name= $app_hostname
$vmcustomize_os.identity.domain=$app_domain