VMware Cloud Community
aamst
Contributor
Contributor

Configuration parameters of VM - hardeningguide

Hello friends.

I have a problem. I need to change configuration parameters of VM in accordance with the hardening guide.

How I did it: I power off the VM then change parameters and then power it on - and everything works.

I have a really critical for bussiness VMs and I cant power them off. How can I change these parameters ?

I was trying to change the vmx file on running machine, but there is no result.

Please help! Thanks!

Reply
0 Kudos
8 Replies
NealeC
Hot Shot
Hot Shot

I'm sorry to say you cannot (and you should not)

VMware KB: Tips for editing a .vmx file

  • The virtual machine actively writes to its .vmx file. Never edit this file while its virtual machine is running.

So you really need to organise an outage.  You could minimise the outage by having a powercli script to

1. Shut down the guest gracefully

2. Edit the settings (or edit/replace the vmx file)

3. Restart the VM

-------------- If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Chris Neale VCIX6-NV;vExpert2014-17;VCP6-NV;VCP5-DCV;VCP4;VCA-NV;VCA-DCV;VTSP2015;VTSP5;VTSP4 http://www.chrisneale.org http://www.twitter.com/mrcneale
aamst
Contributor
Contributor

Can you send me a manual how to use the powercli? I have never used it before.

Thanks

Reply
0 Kudos
NealeC
Hot Shot
Hot Shot

Hi Aamst

The documentation is here.

vSphere PowerCLI Documentation

You would need to download and install powercli onto a server or client machine that can connect to your vCenter

A very rough guide (as I don't know your environment or what values in the vm config you are changing)

  1. Download and install powercli on a computer that can connect to vcenter (or install it on your vcenter!)
  2. Open a powercli window
  3. Connect to your vcenter server using the command
    Connect-VIServer SERVERNAMEorIP
  4. Once connected then stop the vm with
    Shutdown-VMGuest VMNAMEINVCENTER
  5. Edit the setting either manually as you have been doing or if it is a parameter listed in here
    Set-VM - vSphere PowerCLI Cmdlets Reference
    e.g say you wanted to change the VM memory to 8GB
    Set-VM VMNAMEINVCENTER -MemoryMB 8192
  6. Then restart the vm
    Start-VM VMNAMEINVCENTER

And you should be done.

Obviously you have to swap the bits in capitals with the servername or IP of your vcenter for #3 and the name of the VM in vcenter for #4, #5 and #6

It is possible to put this into a single .ps1 file and run it as a script but if you're new to powershell it's good to step through the actions so you can see the output.

Hope that helps.

-------------- If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Chris Neale VCIX6-NV;vExpert2014-17;VCP6-NV;VCP5-DCV;VCP4;VCA-NV;VCA-DCV;VTSP2015;VTSP5;VTSP4 http://www.chrisneale.org http://www.twitter.com/mrcneale
Reply
0 Kudos
NealeC
Hot Shot
Hot Shot

Actually I remembered that you mentioned in your title you are doing vm hardening.

There is a blog post on how to automate (using powercli) the addition of advanced options to VMs

I would download and install powercli first.  Get used to running a command or two.  Then move on to following this blog post on how to create an option file which contains the settings you wish to add/change on lots of VMs

Automate the Hardening of Your Virtual Machine VMX Configurations | VMware vSphere Blog - VMware Blo...

I think that is exactly what you're looking for 😉

-------------- If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Chris Neale VCIX6-NV;vExpert2014-17;VCP6-NV;VCP5-DCV;VCP4;VCA-NV;VCA-DCV;VTSP2015;VTSP5;VTSP4 http://www.chrisneale.org http://www.twitter.com/mrcneale
aamst
Contributor
Contributor

thanks! I will try it!

Reply
0 Kudos
aamst
Contributor
Contributor

oh. PowerCLI can work only on Windows platform. but my vCenter on SUSE.

What can I do ?

Reply
0 Kudos
krish290785
Enthusiast
Enthusiast

However, You can install the powercli on other windows machines in your environment and connect to the vCenter using the standard cmdlets. Its not mandate that you have to run powercli on vCenter only.

-Bala Krishna Gali If the above info is useful, please mark answer as correct or helpful.
Reply
0 Kudos
NealeC
Hot Shot
Hot Shot

You only need to install powercli on a computer that can connect to your vcenter.

Wherever you run vsphere client/web client from now will be the perfect place to install powercli


-------------- If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Chris Neale VCIX6-NV;vExpert2014-17;VCP6-NV;VCP5-DCV;VCP4;VCA-NV;VCA-DCV;VTSP2015;VTSP5;VTSP4 http://www.chrisneale.org http://www.twitter.com/mrcneale
Reply
0 Kudos