Guide to controlling Windows shutdown behavior
Azure Lab Services provides cost controls to ensure that Windows virtual machines (VMs) aren't running unexpectedly:
- Set a schedule
- Set quotas for students
- Automatic shutdown policies
- Disconnect users when virtual machines are idle
- Shut down virtual machines when users disconnect
- Shut down virtual machines when users don't connect
However, a student may use Windows shutdown command to turn off the VM. If Azure Lab Services' stop button or automatic shutdown policies aren't used, of Azure Lab Services still thinks the VM is being used.
To help you prevent this situation from happening, this guide provides steps to remove the Windows shutdown command from the Start menu. The disconnect command is still available for students. The Windows disconnect command will trigger the lab policy (if enabled) that shuts down the VM when users disconnect.
Remove Windows shutdown command from Start menu
Windows Local Group Policy settings also allow you to remove the shutdown command from the Start menu.
To remove the shutdown command, you can connect to the template VM and execute the below PowerShell script.
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "HidePowerOptions" -Value 1 -Force
Or, you can choose to follow these manual steps using the template VM:
Press the Windows key, type gpedit, then select Edit group policy (Control panel).
Go to Computer Configuration > Administrative Templates > Start Menu and Taskbar.
Right-click Remove and prevent access to the Shut Down, Restart, Sleep, and Hibernate commands, and select Edit.
Select the Enabled setting. Select OK:
Notice that the shutdown command no longer appears under Windows Start menu. Only the Disconnect command appears.
Next steps
- As an educator, enable automatic shutdown policies.
- As an educator, prepare Windows template VM for the lab.
- As an educator, publish the template VM.
Feedback
Submit and view feedback for