Seit der Einführung von Single Sign-On (SSO) für die Anmeldung bei AVD Session Hosts besteht das Problem, dass bei einem Session Lock die Sitzung getrennt wird. Das liegt daran, dass der Sperrbildschirm keine modernen Optionen zum Entsperren der Sitzung bietet. Aus Sicherheitsgründen wurde die Sitzung getrennt, mit der Annahme, dass eine erneute Anmeldung schnell und problemlos möglich ist.
In meiner Erfahrung haben viele Kunden kurze Bildschirm-Sperrzeiten, oft 15 Minuten oder weniger, da dies auch auf physischen Geräten so eingestellt ist. Das führt dazu, dass die Verbindung in der Regel mehrmals täglich wiederhergestellt werden muss. Die einzige Lösung bestand bisher darin, auf Single Sign-On zu verzichten.
Seit Mitte September 2024 gibt es nun endlich die Möglichkeit, dieses Verhalten anzupassen. Ursprünglich wurde im Artikel beschrieben, wie dies über Intune und GPO sowie über die Registry gesteuert werden kann. Dafür habe ich eine Scripted Action für Nerdio erstellt, die verwendet werden kann, um die Session Hosts entsprechend zu konfigurieren. Dieses Skript kann jedoch auch auf andere Weise genutzt werden. Aktuell ist im Arikel auch nur noch der Weg via Intune und GPO beschrieben.
Scripted Action
Die folgende Scripted Action kann in Nerdio importiert werden. Die Parameter lassen sich konfigurieren, wenn die Scripted Action zu einem Deployment-Schritt hinzugefügt wird:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
#name: Configure session lock behavior #description: Configure the session lock behavior #execution mode: Combined #tags: beckmann.ch <# Notes: When single sign-on is enabled and the remote session is locked, either by the user or by policy, the session is instead disconnected and a dialog is shown to let users know they were disconnected. Users can choose the Reconnect option from the dialog when they are ready to connect again. This is done for security reasons and to ensure full support of passwordless authentication. If you prefer to show the remote lock screen instead of disconnecting the session, you can change the behavior by setting the following registry key: Key: HKLM\Software\Policies\Microsoft\Windows NT\Terminal Services Type: REG_DWORD Value name: fdisconnectonlockmicrosoftidentity 0 Show the remote lock screen. 1 Disconnect the session. More information, like supported OS versions, can be found here: https://learn.microsoft.com/azure/virtual-desktop/configure-session-lock-behavior More additional background information can be found here: https://learn.microsoft.com/en-us/azure/virtual-desktop/configure-single-sign-on?tabs=registry#session-lock-behavior #> param ( [Parameter( Mandatory = $true, HelpMessage = "Set the session lock behavior. 0 = Show the remote lock screen. 1 = Disconnect the session." )] [ValidateSet('0', '1')] [int]$lockScreen = 1 ) $ErrorActionPreference = 'Stop' Write-Output "Configure session lock behavior" Write-Output "Setting session lock behavior to $lockScreen" $regPath = "HKLM:\Software\Policies\Microsoft\Windows NT\Terminal Services" $regName = "fdisconnectonlockmicrosoftidentity" $regValue = $lockScreen try { If (!(Test-Path $regPath)) { New-Item -Path $regPath -Force } Write-Output "Setting registry key: $regPath\$regName to $regValue" If (Get-ItemProperty -Path $regpath -Name $regName -ErrorAction SilentlyContinue) { Write-Output "Registry key $regPath\$regName already exists. Updating value to $regValue" Set-ItemProperty -Path $regPath -Name $regName -Value $regValue -Type DWORD } Else { Write-Output "Registry key $regPath\$regName does not exist. Creating key with value $regValue" New-ItemProperty -Path $regPath -Name $regName -Value $regValue -PropertyType DWORD } } catch { Write-Output "Encountered error. $_" Throw $_ } Write-Output "Session lock behavior configured" |
Verwendung
Um die Scripted Action nutzen zu können, fügt man sie einer Scripted Action Group hinzu und definiert die entsprechenden Werte:

Es ist auch möglich, die Konfiguration bei der Bereitstellung der VM anzupassen:

Abschluss
Natürlich kann das Verhalten auch weiterhin über Intune und GPO gesteuert werden. Ich bevorzuge jedoch, solche Einstellungen direkt beim Erstellen des Hosts anzuwenden. Da ich zunehmend Implementierungen mit Microsoft Entra ID Only durchführe, bieten sich die Scripted Actions an, um diese Einstellungen direkt von Beginn an zu konfigurieren.