Automation

 View Only
  • 1.  Schedule Guest OS to change during reboot.

    Posted Nov 09, 2018 02:20 PM

    I am looking to use PowerCli to script some changes.  Most of our Windows 2016 servers were setup before Windows 2016 was an option as a guest OS.  I would like to script changing their Guest OS setting.

    Is it possible to change the Guest OS setting while a server is powered on?  (even if it doesn't take affect until a reboot).

    Or is it possible to schedule it to change during a reboot, in the same manner you can use .ScheduledHardwareUpgradeInfo for hardware changes?



  • 2.  RE: Schedule Guest OS to change during reboot.

    Posted Nov 09, 2018 02:35 PM

    You can do that anytime.

    Something like this

    Get-VM -Name MyVM |

    Set-VM -GuestId windows9Server64Guest -Confirm:$false

    Note that this value is only used when creating a VM



  • 3.  RE: Schedule Guest OS to change during reboot.

    Posted Nov 09, 2018 03:05 PM

    That works well if the VM is powered off.  I am trying to set the change so it will take affect on reboot (since it is not a change allowed when powered on).

    Thanks for the try.



  • 4.  RE: Schedule Guest OS to change during reboot.

    Posted Nov 09, 2018 03:28 PM

    Yes, you are right. I tested with a VM that already had windows9Server64Guest as its guest identifier.

    Doesn't seem to be a method to change that while powered on, or prep it for the next reboot.



  • 5.  RE: Schedule Guest OS to change during reboot.

    Posted Nov 09, 2018 03:12 PM

    Something like this (which sets the compatibility to be updated on reboot):

    $vm = Get-VM -Name VMGuestName

    $vm.ExtensionData.Config.ScheduledHardwareUpgradeInfo

    $spec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec

    $spec.ScheduledHardwareUpgradeInfo = New-Object -TypeName VMware.Vim.ScheduledHardwareUpgradeInfo

    $spec.ScheduledHardwareUpgradeInfo.UpgradePolicy = "always"

    $spec.ScheduledHardwareUpgradeInfo.VersionKey = "vmx-14"

    $spec.ScheduledHardwareUpgradeInfo.ScheduledHardwareUpgradeStatus = "pending"

    $vm.ExtensionData.ReconfigVM_Task($spec)