| | | | | | |

Resolving Unexpected Windows 11 Multi-Session License Key Changes in Azure Virtual Desktop with PowerShell Automation

Resolving Unexpected Windows 11 Multi-Session License Key Changes in Azure Virtual Desktop with PowerShell Automation

I recently encountered a unique issue within my Azure Virtual Desktop (AVD) environment running Windows 11 Enterprise Multi-Session. This problem specifically arose in the EASTUS region, where the product key on some session hosts unexpectedly changed from Windows 11 Enterprise Multi-Session to Windows 11 Enterprise only. Oddly, I had other AVD environments in different regions using the exact same Marketplace image, yet they didn’t experience this issue.

To investigate further, I deployed a new session host in a fresh host pool, again using the same Marketplace image in EASTUS. However, the issue repeated: the machine reverted to a Windows 11 Enterprise only license instead of maintaining its Multi-Session license.

After troubleshooting, I contacted Microsoft, who provided a working key specifically for Windows 11 Enterprise Multi-Session. Applying this key immediately restored the session host to its intended Multi-Session state, bringing the functionality back to normal.

As you can imagine, performing these steps manually on multiple session hosts would be tedious, especially with users relying on uninterrupted access to the environment. To streamline this process, I created a PowerShell script that automates these steps, saving time and ensuring consistent, accurate results across the environment.

Screenshots

Azure Virtual Desktop – Session Host version changed from Multi-session to Single Session

What it should look like:

What it looks does look like:

The Solution: A Script to Automate Windows Product Key Reset and Activation

To make this solution more efficient, I created a PowerShell script that performs the following actions in sequence:

  1. Performs a DNS lookup to check network connectivity to the Key Management Service (KMS) endpoint.
  2. Checks the current product key on the session host using slmgr /dlv.
  3. Uninstalls the incorrect key, installs the correct Windows 11 Enterprise Multi-Session key, and then activates the product.
  4. Logs the results of each step so that you can easily monitor the process and verify success.

Running the Script on Your Session Host

Run the script locally on the affected session hosts within your Azure Virtual Desktop (AVD) environment. By executing the script directly on the session host, you ensure that the tools needed for product key management are fully available and functional.

The script can be found on my GitHub Repo: HERE

A screenshot of a computer

Description automatically generated

Steps to Run the Script on Your Session Host:

  1. Connect to the Session Host:
    • Use Remote Desktop (RDP) to connect directly to the Azure Virtual Desktop session host where the product key has changed from Windows 11 Enterprise Multi-Session to Windows 11 Enterprise only.
  2. Open PowerShell with Administrator Privileges:
    • Once you’re logged into the session host, open PowerShell as an administrator. To do this, search for “PowerShell” in the Start menu, right-click, and select Run as Administrator.
  3. Execute the Script:
    • Copy the script below into your PowerShell window and execute it directly on the session host. The script automates the necessary steps to reset the product key and re-activate the session host to its correct Multi-Session state.

A computer screen with text on it

Description automatically generated

  1. Monitor the Script’s Output:
    • As the script runs, it will log each step and display the results directly in the PowerShell window. Additionally, the log will be saved to a process_log.txt file, providing a detailed record of the entire process.

A computer screen with a message box

Description automatically generated

A computer screen with green text

Description automatically generated

A computer screen with green text

Description automatically generated

A screenshot of a computer

Description automatically generated

Why Local Execution is Required

Running the script directly on the session host ensures that all necessary product key management tools (such as slmgr.vbs) are available and functional. This method resolves the issue by resetting the Windows product key and restoring the session host to its intended Windows 11 Enterprise Multi-Session state.

This approach guarantees that your session hosts are correctly re-licensed, restoring full multi-session functionality and resolving any licensing conflicts.

Why This Script Works

The script automates the entire process of resetting and activating the Windows 11 Enterprise Multi-Session key. This includes checking connectivity, managing the product key using slmgr, and ensuring the host is back in a multi-session state.

Each step provides clear feedback, making it easy to identify if any issues occur during the process.

Your Session host will now show that it is a Multi-Session host again in the Azure Portal.

Conclusion

This issue may not be widespread, but if you encounter it, the steps I’ve outlined here—combined with the provided PowerShell script—should make resolving the problem much easier. Automating repetitive tasks like this not only speeds up the process but also ensures consistency across your AVD environment.

I’d like to extend a special thanks to the Microsoft team for providing the correct keys that helped resolve the issue. With this automation in place, my session hosts are now fully operational as Multi-Session machines again, and I hope this helps anyone facing a similar challenge.

About the Author

Shaun Hardneck is a Microsoft Cloud Security Specialist with a focus on optimizing and securing Azure Virtual Desktop environments. With years of experience managing Microsoft cloud technologies, Shaun shares practical solutions and insights on his blog, ThatLazyAdmin.com. You can reach him at shaun@thatlazyadmin.com for consulting or troubleshooting assistance in your cloud journey.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *