Automation

 View Only
Expand all | Collapse all

Inconsistent behavior with New-AdvancedSetting on running VMs

  • 1.  Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Jul 19, 2022 04:23 PM

    We're seeing inconsistent results using new-advancedsetting on running VMs in our environment.  For years we've been able to do something like "Get-VM $VM | New-AdvancedSetting -Name isolation.tools.paste.disable -Value true -Confirm:$false" to have it add a setting on the fly.

    When running in some locations we're getting "New-AdvancedSetting The attempted operation cannot be performed in the current state (Powered on)". 

    It seems to be isolated to a single vCenter, oddly.

    Anyone seen this before?



  • 2.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Jul 19, 2022 04:42 PM

    Afaik, this is now working correctly.
    The VM needs to be powered off to be able to set that setting.



  • 3.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Jul 19, 2022 05:09 PM

    That's interesting.  Its been called out in the STIG controls for years that it can be done live.

    https://www.stigviewer.com/stig/vmware_vsphere_virtual_machine_version_6/2015-12-09/finding/V-64045



  • 4.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Jul 19, 2022 06:25 PM

    The Web Client requires the VM to be powered off, the same as is stated in KB57122

    The STIG Viewer explicitly states

    LucD_0-1658255030219.png

    I leave it open to the VMW people if that was a "feature" in PowerCLI that has now been corrected



  • 5.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Jul 19, 2022 06:36 PM

    If you still want to be able to do this on a powered on VM, just use the API method



  • 6.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Nov 17, 2022 07:10 AM

    Hi Luc,

    I ran into the same issue and tried your API Method with exactly the same result:

    Exception calling "ReconfigVM" with "1" argument(s): "The attempted operation cannot be performed in the current state (Powered on)."
    At line:7 char:1
    + $vm.ExtensionData.ReconfigVM($spec)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : VimException

    Any other ideas or is this the new normal?



  • 7.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Nov 17, 2022 07:41 AM

    Then it looks like they closed this loophole.
    WHich vSphere version are you running this on?



  • 8.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Nov 17, 2022 07:52 AM

    Thank you for the fast reply! That would be bad if is closed now, we were setting all the VM hardening settings over years with the same script (where we used the API method already) and were just adding settings when the Hardening Guide was updated. Powercycling thousands of (customer) VMs is almost impossible for us...

    We´re running our vCenter on 7.0.3f and the Hosts on 7.0.3e



  • 9.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Nov 17, 2022 07:56 AM

    Perhaps you should open an SR or contact your TAM.

    But I'm afraid that this will not really help, since it was an undocumented feature after all.
    The documentation clearly states that the VM needs to be powered off.



  • 10.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Aug 14, 2023 11:14 PM

    Hi Luc,

    I'm looking at setting/creating multiple advanced setting options across a large number of deployed VMs. I don't interact with the API very often. This snippet is helpful. Do you have an example of creating an Option spec with multiple entries?



  • 11.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Aug 15, 2023 08:16 AM

    The ExtraConfig property is an array of OptionValue objects.

    This example applies 3 settings to 3 VMs.
    Adapt as required.



  • 12.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Aug 16, 2023 08:17 PM

    Once again, LucD, you rock as always!

    I was getting an error on the ReconfigVM() implementation with the boolean value but changing $true to 'true' was accepted. Not sure why. I'll still have to do follow up testing to ensure it did indeed take effect but it appears to have.

    But more importantly, you helped me over my stumbling block.

    Thanks, again!



  • 13.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 21, 2024 10:06 PM

    Unfortunately, I tried LucD's example and am still getting the "The attempted operation cannot be performed in the current state (Powered On)." Similar to JoeMoreno, I have multiple vCenters running the same version. Some work fine with the VMs powered on and others don't.



  • 14.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 21, 2024 10:16 PM

    Does it work in the same way when you use the ReconfigVM method?



  • 15.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 21, 2024 10:28 PM

    It did not work with the ReconfigVM method either. Here is the error I get:


     

     



  • 16.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 21, 2024 10:53 PM

    At least that shows it is not a PowerCLI issue.

    A wild shot, are these VMs all on the same HW version?
    And running the same VMware Tools version?



  • 17.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 22, 2024 03:54 PM

    In the environment where it doesn't work it's a mix of HW & Tools versions. To limit some of the variables, I've been testing with a single VM in each that is the same HW version and doesn't even have an OS installed so no Tools version. In the vCenter that doesn't work just having it powered on throws that error. The other one works fine no matter what the state of the VM is.



  • 18.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 22, 2024 04:17 PM

    Since it also happens with the ReconfigVM method it isn't a PowerCLI issue.
    I suggest opening an SR.



  • 19.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 07, 2023 05:07 AM

    Did you guys ever find any workaround for this? other than shutting down the vm and applying the STIG? 

    Like what the thread says I was also running Powercli STIG for the virtual machine since 5.5-to-6.7 and I was always successful in applying the script.  Granted some will take affect after stop-vm/start-vm so it can read the vmx config but it was a much workable issue.  But vsphere 7U3 current state giving has a hard stop with error "The attempted operation cannot be performed in the current state (Powered on)." this is a big issue.  It is hard to imagine we are being required by VMware to shutdown the vm and then apply the vm stig. 

    If you guys find the workaround, I am interested in trying...  Thanks.. 



  • 20.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 07, 2023 06:12 AM

    I'm afraid that this is now working as documented.
    Before it was a "feature".



  • 21.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Feb 07, 2023 03:57 PM

    =(  understand, thank you for the expediate reply....   I am really really bum about it but it is what it is.  I emailed  to see if he can share undocumented hacks but not sure if he will even see my email...  



  • 22.  RE: Inconsistent behavior with New-AdvancedSetting on running VMs

    Posted Jul 15, 2023 09:46 PM

    This is isnteresting. I'm Facing this right now and found this conversation but looks like there's not an answer.
    I have 4 Vcenters all of them running Vcenter 7.0.3L ESXi Version 7.0.3. Apply New-AdvancedSettingIt works in 2 Vcenters with PowerOn VMs, but it does not work on the other 2 Vcenters, failing with the mentioined error "New-AdvancedSetting The attempted operation cannot be performed in the current state (Powered on)"

    Same Script, same settings to be applied, same Vcenter Version, Same ESXi Version, Same OS version in the VMs but result is not consistent.