Skip to content

Commit 89e7925

Browse files
authored
Merge pull request #109751 from nicolehaugen/SettingWindowsPolicies
How-to article on controlling Windows shutdown behavior
2 parents f303938 + cfe2187 commit 89e7925

File tree

10 files changed

+121
-8
lines changed

10 files changed

+121
-8
lines changed

articles/lab-services/classroom-labs/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
href: how-to-enable-nested-virtualization-template-vm-using-script.md
103103
- name: Prepare a Windows template VM
104104
href: how-to-prepare-windows-template.md
105+
- name: Control Windows shutdown behavior
106+
href: how-to-windows-shutdown.md
105107
- name: View support information (instructor)
106108
href: lab-creator-support-information.md
107109
- name: Connect to VMs in classroom labs (student)

articles/lab-services/classroom-labs/how-to-prepare-windows-template.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ ms.author: enewman
1414
---
1515
# Guide to setting up a Windows template machine in Azure Lab Services
1616

17-
If youre setting up a Windows 10 template machine for Azure Lab Services, here are some best practices and tips to consider. The configuration steps below are all optional. However, these preparatory steps could help make your students be more productive, minimize class time interruptions, and ensure that they're using the latest technologies.
17+
If you're setting up a Windows 10 template machine for Azure Lab Services, here are some best practices and tips to consider. The configuration steps below are all optional. However, these preparatory steps could help make your students be more productive, minimize class time interruptions, and ensure that they're using the latest technologies.
1818

1919
>[!IMPORTANT]
20-
>This article contains PowerShell snippets to streamline the machine template modification process. For all the PowerShell scripts shown, youll want to run them in Windows PowerShell with administrator privileges. In Windows 10, a quick way of doing that is to right-click the Start Menu and choose the "Windows PowerShell (Admin)".
20+
>This article contains PowerShell snippets to streamline the machine template modification process. For all the PowerShell scripts shown, you'll want to run them in Windows PowerShell with administrator privileges. In Windows 10, a quick way of doing that is to right-click the Start Menu and choose the "Windows PowerShell (Admin)".
2121
2222
## Install and configure OneDrive
2323

@@ -61,7 +61,7 @@ If you are on a machine that is not using Active Directory, users can manually m
6161

6262
If your virtual machine is connected to Active Directory, you can set the template machine to automatically prompt your students to move the known folders to OneDrive.
6363

64-
Youll need to retrieve your Office Tenant ID first. For further instructions, see [find your Office 365 Tenant ID](https://docs.microsoft.com/onedrive/find-your-office-365-tenant-id). You can also get the Office 365 Tenant ID by using the following PowerShell.
64+
You'll need to retrieve your Office Tenant ID first. For further instructions, see [find your Office 365 Tenant ID](https://docs.microsoft.com/onedrive/find-your-office-365-tenant-id). You can also get the Office 365 Tenant ID by using the following PowerShell.
6565

6666
```powershell
6767
Install-Module MSOnline -Confirm
@@ -128,7 +128,7 @@ New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\OneDrive\DiskSpaceChec
128128

129129
### Install Microsoft Office 365
130130

131-
If your template machine needs Office, we recommend installation of Office through the [Office Deployment Tool (ODT)](https://www.microsoft.com/download/details.aspx?id=49117 ). You will need to create a reusable configuration file using the [Office 365 Client Configuration Service](https://config.office.com/) to choose which architecture, what features youll need from Office, and how often it updates.
131+
If your template machine needs Office, we recommend installation of Office through the [Office Deployment Tool (ODT)](https://www.microsoft.com/download/details.aspx?id=49117 ). You will need to create a reusable configuration file using the [Office 365 Client Configuration Service](https://config.office.com/) to choose which architecture, what features you'll need from Office, and how often it updates.
132132

133133
1. Go to [Office 365 Client Configuration Service](https://config.office.com/) and download your own configuration file.
134134
2. Download [Office Deployment Tool](https://www.microsoft.com/download/details.aspx?id=49117). Downloaded file will be `setup.exe`.
@@ -180,7 +180,7 @@ We recommend having all Microsoft Store apps be updated to their latest versions
180180
3. Select **Download** and updates from the drop-down menu.
181181
4. Click **Get update** button.
182182

183-
You can also use Powershell to update Microsoft Store applications that are already installed.
183+
You can also use PowerShell to update Microsoft Store applications that are already installed.
184184

185185
```powershell
186186
(Get-WmiObject -Namespace "root\cimv2\mdm\dmmap" -Class "MDM_EnterpriseModernAppManagement_AppManagement01").UpdateScanMethod()
@@ -203,7 +203,7 @@ New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AU"
203203
If you need additional languages installed on the virtual machine, you can add them through the Microsoft Store.
204204

205205
1. Launch Microsoft Store
206-
2. Search for language pack
206+
2. Search for "language pack"
207207
3. Choose language to install
208208

209209
If you are already logged on to the template VM, use ["Install language pack" shortcut](ms-settings:regionlanguage?activationSource=SMC-IA-4027670) to go directly to the appropriate settings page.
@@ -229,3 +229,6 @@ Install other apps commonly used for teaching through the Windows Store app. Sug
229229
## Conclusion
230230

231231
This article has shown you optional steps to prepare your Windows template VM for an effective class. Steps include installing OneDrive and installing Office 365, installing the updates for Windows and installing updates for Microsoft Store apps. We also discussed how to set updates to a schedule that works best for your class.
232+
233+
## Next steps
234+
See the article on how to control Windows shutdown behavior to help with managing costs: [Guide to controlling Windows shutdown behavior](how-to-windows-shutdown.md)
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: Guide to controlling Windows shutdown behavior in Azure Lab Services | Microsoft Docs
3+
description: Steps to automatically shutdown an idle Windows virtual machine and remove the Windows shutdown command.
4+
services: lab-services
5+
documentationcenter: na
6+
author: spelluru
7+
manager:
8+
editor: ''
9+
10+
ms.service: lab-services
11+
ms.topic: article
12+
ms.date: 3/30/2020
13+
ms.author: spelluru
14+
---
15+
16+
# Guide to controlling Windows shutdown behavior
17+
18+
Azure Lab Services provides several cost controls to ensure that Windows virtual machines (VMs) are not running unexpectedly:
19+
- [Set a schedule](https://docs.microsoft.com/azure/lab-services/classroom-labs/tutorial-setup-classroom-lab#set-a-schedule-for-the-lab)
20+
- [Set quotas for users](https://docs.microsoft.com/azure/lab-services/classroom-labs/how-to-configure-student-usage#set-quotas-for-users)
21+
- [Enable automatic shutdown on disconnect](https://docs.microsoft.com/azure/lab-services/classroom-labs/how-to-enable-shutdown-disconnect)
22+
23+
Even with these cost controls, there are situations where a Windows VM may unexpectedly continue to run; and as a result, deduct from the student's quota:
24+
25+
- **RDP window is left open**
26+
27+
When a student connects to their VM using RDP, they may inadvertently leave the RDP window open. As long as the RDP window remains open, the **automatic shutdown on disconnect** setting will never take effect since it is only triggered after the RDP session is disconnected.
28+
29+
- **Windows shutdown command is used to turn off the VM**
30+
31+
A student may use Windows shutdown command, or other shutdown mechanisms provided within Windows, to turn off the VM instead of using [Azure Lab Services' stop button](https://docs.microsoft.com/azure/lab-services/classroom-labs/how-to-use-classroom-lab#start-or-stop-the-vm). When this happens, from the perspective of Azure Lab Services, the VM is still being used.
32+
33+
To help you prevent these situations from happening, this guide provides steps to automatically shutdown an idle Windows VM and remove the Windows shutdown command from the **Start** menu.
34+
35+
> [!NOTE]
36+
> A VM may also unexpectedly deduct from the quota when the student starts their VM, but never actually connects to it using RDP. This guide does *not* currently address this scenario. Instead, students should be reminded to immediately connect to their VM using RDP after they start it; or, they should stop the VM.
37+
38+
## Automatic RDP disconnect and shutdown for idle VM
39+
40+
Windows provides **Local Group Policy** settings that you can use to set a time limit to automatically disconnect an RDP session when it becomes idle. A session is determined to be idle when there is *not* any mouse\keyboard input. Any long running activities that don't involve mouse\keyboard input cause the VM to be in an idle state. This includes executing a long query, streaming video, compiling, etc. Depending on your class's needs, you can choose to set the idle time limit so that it's long enough to handle these types of activities. For example, you can set the idle time limit to 1 or more hours if needed.
41+
42+
Here is the student's experience when you configure the **idle session limit** in combination with the [**automatic shutdown on disconnect**](https://docs.microsoft.com/azure/lab-services/classroom-labs/how-to-enable-shutdown-disconnect) setting:
43+
1. The student connects to their Windows VM using RDP.
44+
2. When the student leaves their RDP window open and the VM is idle for the **idle session limit** that you specified (such as 5 minutes), the student will see the following dialog:
45+
46+
![Idle time limit expired dialog](../media/how-to-windows-shutdown/idle-time-expired.png)
47+
48+
1. If the student does *not* click **OK**, their RDP session will automatically disconnect after 2 minutes.
49+
2. After the RDP session disconnects, once the specified time frame for the **automatic shutdown on disconnect** setting is reached, the VM is automatically shutdown by Azure Lab Services.
50+
51+
### Set RDP idle session time limit on the template VM
52+
53+
To set the RDP session idle time limit, you can connect to the template VM and execute the below PowerShell script.
54+
55+
```powershell
56+
# The MaxIdleTime is in milliseconds; by default, this script sets MaxIdleTime to 15 minutes.
57+
$maxIdleTime = 15 * 60 * 90
58+
59+
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" -Name "MaxIdleTime" -Value $maxIdleTime -Force
60+
```
61+
Or, you can choose to follow these manual steps using the template VM:
62+
63+
1. Press the Windows key, type **gpedit**, then select **Edit group policy (Control panel)**.
64+
65+
1. Go to **Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits**.
66+
67+
![Local group policy editor](../media/how-to-windows-shutdown/group-policy-idle.png)
68+
69+
1. Right-click **Set time limit for active but idle Remote Desktop Services sessions**, and click **Edit**.
70+
71+
1. Enter the following settings, and then click **OK**:
72+
1. Select **Enabled**.
73+
1. Under **Options**, specify the **Idle session limit**.
74+
75+
![Idle session limit](../media/how-to-windows-shutdown/edit-idle-time-limit.png)
76+
77+
1. Finally, to combine this behavior with the **automatic shutdown on disconnect** setting, you should follow steps in the how-to article: [Enable automatic shutdown of VMs on disconnect](https://docs.microsoft.com/azure/lab-services/classroom-labs/how-to-enable-shutdown-disconnect).
78+
79+
## Remove Windows shutdown command from Start menu
80+
81+
Windows **Local Group Policy** settings also allow you to remove the shutdown command from the **Start** menu.
82+
83+
To remove the shutdown command, you can connect to the template VM and execute the below PowerShell script.
84+
85+
```powershell
86+
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "HidePowerOptions" -Value 1 -Force
87+
```
88+
89+
Or, you can choose to follow these manual steps using the template VM:
90+
91+
1. Press the Windows key, type **gpedit**, then select **Edit group policy (Control panel)**.
92+
93+
1. Go to **Computer Configuration > Administrative Templates > Start Menu and Taskbar**.
94+
95+
![Local group policy editor](../media/how-to-windows-shutdown/group-policy-shutdown.png)
96+
97+
1. Right-click **Remove and prevent access to the Shut Down, Restart, Sleep, and Hibernate commands**, and click **Edit**.
98+
99+
1. Select the **Enabled** setting and then click **OK**:
100+
101+
![Shutdown setting](../media/how-to-windows-shutdown/edit-shutdown.png)
102+
103+
1. Notice that the shutdown command no longer appears under Windows **Start** menu; only the **Disconnect** command appears.
104+
105+
![Shutdown command](../media/how-to-windows-shutdown/start-menu.png)
106+
107+
## Next steps
108+
See the article on how to prepare a Windows template VM: [Guide to setting up a Windows template machine in Azure Lab Services](how-to-prepare-windows-template.md)

articles/lab-services/classroom-labs/setup-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Lab Services uses a pay-as-you go pricing model which means that you only pay fo
7676
Students are each assigned their own VM that is assigned to them for the lifetime of the lab. They can choose to:
7777

7878
- Save directly to the VM.
79-
- Save to an external repository, such as OneDrive, GitHub, etc.
79+
- Save to an external location, such as OneDrive, GitHub, etc.
8080

8181
To use OneDrive, you may choose to configure this automatically for students on their lab VMs. Additional information on this is provided below.
8282

@@ -150,4 +150,4 @@ See the following articles:
150150

151151
- [Track usage of a classroom lab](tutorial-track-usage.md)
152152

153-
- [Access a classroom lab](tutorial-connect-virtual-machine-classroom-lab.md)
153+
- [Access a classroom lab](tutorial-connect-virtual-machine-classroom-lab.md)
182 KB
Loading
152 KB
Loading
72 KB
Loading
64.8 KB
Loading
5.54 KB
Loading
19.7 KB
Loading

0 commit comments

Comments
 (0)