Control Windows shutdown behavior in lab virtual machines

In this article, you learn how to remove the shutdown command from the Windows Start menu in lab virtual machines in Azure Lab Services. When a lab user performs a shutdown in the operating system instead of stopping the lab virtual machine, the shutdown might interfere with the Azure Lab Services cost control measures.

Azure Lab Services provides different cost control measures, such as lab schedules, quota hours, and automatic shutdown policies.

When the Windows shutdown command is used to turn off a lab virtual machine, the service considers the lab virtual machine to still be running and accumulating costs. Instead, lab users should use the stop functionality of the lab virtual machine. To prevent inadvertently shutting down the lab virtual machine, you can remove the shutdown command from the Windows Start menu.

Lab users can still disconnect from the lab virtual machine. The Windows disconnect command triggers the lab policy (if enabled) that shuts down the lab virtual machine when users disconnect.

Remove Windows shutdown command from Start menu

You can use Windows local group policy settings to remove the shutdown command from the Windows Start menu. Modify this policy on the lab template virtual machine to ensure that the change applies to all lab virtual machines.

To configure a local group policy setting by using PowerShell:

  1. Connect to the lab template virtual machine by using RDP.

  2. Run the following PowerShell command to disable the shutdown option in the Start menu:

    Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "HidePowerOptions" -Value 1 -Force
    

Alternately, you can manually change the local group policy setting:

  1. Connect to the lab template virtual machine by using RDP.

  2. Press the Windows key, type gpedit, then select Edit group policy (Control panel).

  3. Go to Computer Configuration > Administrative Templates > Start Menu and Taskbar.

    Screenshot of Group Policy Editor in Windows.

  4. Right-select Remove and prevent access to the Shut Down, Restart, Sleep, and Hibernate commands, and then select Edit.

  5. Select the Enabled setting, and then select OK.

    Screenshot of Remove and prevent access to the Shut Down, Restart, Sleep, and Hibernate commands dialog in Windows.

  6. Notice that the shutdown command no longer appears under Windows Start menu. Only the Disconnect command appears.

    Screenshot of the Start menu in Windows.  The power button and disconnect item are highlighted.

Next steps