VMware Cloud Community
staino83
Contributor
Contributor

Editing /etc/hosts in ESXi 5 hosts using powercli

I have been searching the web on how to modify the /etc/hosts file using powercli

Is it possible to edit files in /etc using powercli?

The reason is I am required to modify all /etc/hosts files and SSL is not a nice solution to managing my 100+ host environment.

Regards

Reply
0 Kudos
3 Replies
MartinAmaro
Expert
Expert

What exactly are you trying to acomplish?

If all you need to do is update the DNS and routing settings then you can use Set-VMHostNetwork

http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Set-VMHostNetwork.html

also have you consider a simple WINSCP batch script to copy the master /etc/hosts file to all 100+ hosts?

here is a quick example

http://nixcraft.com/windows-xp-2000-2003-server-administration/18569-winscp-batch-file.html

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful.
Reply
0 Kudos
LucD
Leadership
Leadership

There are no cmdlets to do this directly I'm afraid.

There is a way by using the Set-VMHostFirmware cmdlet.

See the functions in chapter 12 in the PowerCLI Reference Book. The example is for manipulating the proxy.xml file, but the same principle could be used for other system files.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
viktorious
VMware Employee
VMware Employee

I ran into the following article regarding this issue; although it's not powershell it sounds as an interesting alternative:

http://blogs.vmware.com/vsphere/2012/06/using-vclis-vifs-for-more-than-just-datastore-file-managemen...