VMware Cloud Community
virtualhobbit
Enthusiast
Enthusiast
Jump to solution

How to remove answer files from vCenter

I am trying to pre-populate vCenter with host IP address details, so when a stateless host boots using Auto Deploy it is effectively "zero touch" and can get to work straight away.

I'm using Daniel Hiltgen's script which can be found here: Script to pre-answer static IP addresses for Auto Deploy hosts (stateless ESXi). I'm identifying hosts by mac address, and I have modified the script (using his notes) to reference a dvSwitch.

I've created my CSV file, but every time I tried to run the script I get "Host 192.168.146.111 already has a valid answer file, skipping".  Now I'm not actually sure this is correct, but im testing this in a lab environment and it's possible I've tried every combination of IP address on my LAN.

How can I leverage PowerCLI to see what answer files are defined, and if necessary remove them?

I've tried using Get-View "HostProfileManager" but I didn't get very far.

Any help would be greatly appreciated.

-Mark

Reply
0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can see if an host named ESX1 has an answer file with:

$hostProfileManagerView = Get-View -Id HostProfileManager

$targetHost = Get-VMHost -Name ESX1

$answerFile = $hostProfileManagerView.RetrieveAnswerFile($targetHost.ExtensionData.MoRef)

There is no way to remove an answer file. Howerver you can update an existing answer file. If you remove the check on an existing answerfile in Daniel Hiltgen's script then the answerfile will be updated, if it already exists. To do this, you have to remove the following lines in Daniel's script::

157 if (-not $answerFile) {

182 } else {

183 Write "Host $targetHost already has a valid answer file, skipping."

184 }.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

Reply
0 Kudos
2 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can see if an host named ESX1 has an answer file with:

$hostProfileManagerView = Get-View -Id HostProfileManager

$targetHost = Get-VMHost -Name ESX1

$answerFile = $hostProfileManagerView.RetrieveAnswerFile($targetHost.ExtensionData.MoRef)

There is no way to remove an answer file. Howerver you can update an existing answer file. If you remove the check on an existing answerfile in Daniel Hiltgen's script then the answerfile will be updated, if it already exists. To do this, you have to remove the following lines in Daniel's script::

157 if (-not $answerFile) {

182 } else {

183 Write "Host $targetHost already has a valid answer file, skipping."

184 }.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
Sany_1973
Enthusiast
Enthusiast
Jump to solution

Is there any way to view the current values in the answer file.

Thanks

Reply
0 Kudos