(Windows) Virtual Desktop Optimization Tool now available

Microsoft

Christiaan_Brinkhoff_0-1596206475321.png

 

Optimizing images has always been an important component of preparing images as part of a traditional  Remote Desktop Services (RDS) infrastructure or virtual desktop infrastructure (VDI). Optimizing session hosts, in particular, can increase user density and eventually lower costs. With the Virtual Desktop Optimization Tool, you can optimize your Windows 10, version 2004 multi- and single-session deployments in Windows Virtual Desktop.

 

Note: The information in this post is community-driven; nothing has yet been officially launched by the Windows Virtual Desktop product team. Credit goes to Robert M. Smith and Tim Muessig from Microsoft, previously known as the VDIGuys, for creating this tool and make it available for free for the community.

 

Windows 10 multi-session image name change

As noted in recent announcements, Office 365 ProPlus is now Microsoft 365 apps for Enterprise. With this name change, we have updated the Windows Virtual Desktop image names in Azure Marketplace. As a result, when you are looking for an image in the Azure Marketplace image gallery, you should begin by selecting Windows 10 Enterprise multi-session, version 2004 + Microsoft 365 Apps – Gen1 as your baseline image.

 

Christiaan_Brinkhoff_1-1596206475330.png

 

How the Virtual Desktop Optimization Tool works

The (Windows) Virtual Desktop Optimization Tool disables services in the operating system that you most likely won’t need for your Windows Virtual Desktop session host. To make sure that your line-of-business (LOB) applications continue running as they should, there are some preliminary steps that should first performed.

 

Note: There are settings default disabled when you run the scrip out of the box such as AppX Packages for the Windows Calculator. We strongly suggest analyzing the tool via the JSON files that include the default settings. This also gives you the opportunity to enable them before running the tool so they remain untouched. I'll explain more about this later on in the article.

 

The full list of enhancements for native Windows services will be available soon. Bookmark Run and tune your Remote Desktop Services environment for the latest updates.

 

Expected performance gains

Windows Virtual Desktop value-added services provider and Microsoft partner LoginVSI performed early tests with the Virtual Desktop Optimization Too and gained over 100 users in their internal benchmarking lab environment with a Windows 10, version 2004 single session. We, therefore, assume that this gain will also be possible with Windows 10 Enterprise multi-session.

 

VSImax asserts a maximum number of users that are able to log on to the virtual desktop hosts pool as part of the underlying infrastructure. That number is the "sweet spot" as going over that number will decrease performance for all users. (Thanks to LoginVSI for sharing these results with us.)

 

Login_VSI_Blog_MSFT_Optimizer_Image_4.png

 

Note: We recommend you use simulation tools to test your deployment using both stress tests and real-life usage simulations to ensure that your system is responsive and resilient enough to meet user needs Remember to vary the load size to avoid surprises.

 

Desktops in the Cloud on Performance Optimizations for Windows Virtual Desktop with Robert and Tim (aka VDI Guys)

We recently had the creators of the Virtual Desktop Optimization tool as guests on our Desktops in the Cloud video-podcast. Robert and Tim explained everything you should know, as well as best practices and lessons learned. A must watch in extension to this article. Watch it below. 

 

 

How to use the Virtual Desktop Optimization Tool

The Virtual Desktop Optimization Tool makes it possible to disable uncommon services for virtual desktop environments, such as Windows Virtual Desktop.

 

Note: We recommend that you run the script after the Sysprep (System Preparation) process, most likely as startup script w with a large set of virtual machines. This is due to the AppX Packages that conflict and most likely the sysprep will fail. 

 

  1. Download all scripts from the Virtual-Desktop-Optimization-Tool GitHub repository.
  2. Select Clone or download, followed by Download ZIP.

    Christiaan_Brinkhoff_3-1596206475342.png

Unzip the folder to your Windows Virtual Desktop session host(s) to a specified folder (e.g. C:\Optimize or C:\Temp).

Note: You could also run the scripts as part of your image management procedure e.g. Azure image Builder (AIB) or Azure DevOps.

Christiaan_Brinkhoff_4-1596206475347.png

Important information before running the tool

 

  1. There are settings default disabled when you run the scrip out of the box such as AppX Packages for the Windows Calculator. We strongly suggest analyzing the tool via the JSON files that include the default settings. This also gives you the opportunity to enable them before running the tool so they remain untouched.

  2. You can find the JSON file in the Windows built number folder, under ConfigurationFiles - e.g. C:\Optimize\2004\ConfigurationFiles. 

  3. You've to put the settings to Enabled - that you want to keep as default. Below is the example file for AppX Packages, there are JSON files for Services and scheduled tasks as well.

  4. Another option is to remove the while entry out of the JSON file.

     

    AppxPackages.json - Example Windows Calculator App

      {
        "AppxPackage": "Microsoft.WindowsCalculator",
        "VDIState": "Enabled",
        "URL": "https://www.microsoft.com/en-us/p/windows-calculator/9wzdncrfhvn5",
        "Description": "Microsoft Calculator app"
      },
    Services.json - example Windows Update Service
      {
        "Name": "UsoSvc",
        "VDIState": "Enabled",
        "Description": "Update Orchestrator service, manages Windows Updates. If stopped, your devices will not be able to download and install the latest updates."
      },

 

 

  1. Prepare to launch Windows PowerShell and select Run as Administrator.

    Christiaan_Brinkhoff_5-1596206475350.png

  2. In PowerShell, change the directory to the folder to which you downloaded the scripts, e.g. C:\Optimize or your own specific folder.

    Christiaan_Brinkhoff_6-1596206475351.png

  3. Run the following command:
    Set-ExecutionPolicy -ExecutionPolicy Bypass ​

    Christiaan_Brinkhoff_7-1596206475352.png

  4. Run the Virtual Desktop Optimization Tool using the following command:
    .\Win10_VirtualDesktop_Optimize.ps1 -WindowsVersion 2004 -Verbose​

    Christiaan_Brinkhoff_8-1596206475356.png
    Note: When you use a different version of Windows 10, you must change the WindowsVersion parameter. Version 1803 and later are supported for Windows 10 Enterprise. Windows 10 multi-session support is only available with Windows 10, version 2004 and later.

  5. Select Yes when prompted to reboot the session hosts(s).
  6. Start your Windows Virtual Desktop session.

    Christiaan_Brinkhoff_9-1596206475359.png

     

As you can see in the Task Manager comparison below, the number of threads and handles has decreased noticeably after running the Virtual Desktop Optimization Tool.

Christiaan_Brinkhoff_10-1596206475379.png

 

Do you have any problems with orphaned Start Menu shortcuts after running the tool?

Have the user open Task Manager, then end the following two processes:

  • ShellExperienceHost.exe
  • StartMenuExperienceHost.exe

Have them check the Start Menu and they should be gone.

 

2020-08-01 09_24_22-Window.png

 

Happy optimizing! :)

 

Let us know your feedback on the tool in the comment section below.

 

Prefer to watch and learn? There’s also a video on Azure Academy available later this week by Dean Cefola. You can find it here.

 

40 Replies

@MortenPedholt - Thanks!  Not sure who i overlooked that....

@Robert_Smith 

Can't get this fix to work. ShellExperienceHost.exe is not running, shutting down the StartMenuExperienceHost.exe is not helping. 

Any idea how to fix that? I'm running 2004.

@Christiaan_Brinkhoff @Robert_Smith 

 

Any joy on the cleanup?  We have FSLogix profiles installed and after running I noticed 2 things.

1) Orphaned icons in the Start menu.  Would prefer not to have users have to run a script to clean that up.  Is that the only way?

2) I disable XBox items and snip and sketch breaks, and then I can't re-enable and restart the capture service.

 

Any thoughts or suggestions?


Thanks!

 

Garth

@Christiaan_Brinkhoff This tool shall reset back execution policy to default or instruct to set it only for current execution scope (current process via Set-ExecutionPolicy Bypass -Scope Process) otherwise it

leaves system in undesired security state.

@Christiaan_Brinkhoff 

Hi there, thank you guys for developing this tool. I am testing it and having it execute as a start up script after provisioning the Windows 10 2004 multi-session hosts.  What I have noticed is that the optimization script appears to break the Citrix Workspace App/Receiver.  When the Citrix Receiver is invoked or executed to start a published citrix app, it tries to repair itself.  If I dont run the optimization script, the Citrix Workspace App/Receiver launches correctly.  Has anyone else seen this?

 

Thanks

@Pashar 

 

Personally I have seen this break a lot of stuff.  I've had better luck applying most of the optimizations via GPO.  This doesn't remove the MISX Apps but I honestly think this tool takes a "bull in a china closet" approach on that.

 

My .02...

@Nagorg-Terralogic  - Great idea but does need more testing!

I have an issue when running the tool - it breaks Snip & Sketch. I have excluded the app from being removed. But there seems to be other optimisations happening that breaks it and causes it to crash when pressing Win + Shift + S.

 

Faulting application name: ScreenClippingHost.exe, version: 2001.22012.0.551, time stamp: 0x5f7e6f9b

Faulting module name: ScreenClipping.dll, version: 2001.22012.0.551, time stamp: 0x5f7e6b8c

Exception code: 0x80000003

Fault offset: 0x000000000001b92d

Faulting process id: 0x200

Faulting application start time: 0x01d7061f864d4936

Faulting application path: C:\Windows\SystemApps\MicrosoftWindows.Client.CBS_cw5n1h2txyewy\ScreenClipping\ScreenClippingHost.exe

Faulting module path: C:\Windows\SystemApps\MicrosoftWindows.Client.CBS_cw5n1h2txyewy\ScreenClipping\ScreenClipping.dll

Report Id: 03cc773f-c630-4c66-aea4-49df01a43ccc

Faulting package full name: MicrosoftWindows.Client.CBS_120.2212.551.0_x64__cw5n1h2txyewy

Faulting package-relative application ID: ScreenClipping

 

The app works find before optimisation script is run. Now trying to see what optimisations are causing it to break and exclude those as well.

 

Running on a Windows 10 20H2 image in Azure trying to set up a gold image to update a session pool.

@skp574 

Howdy.  

 

I believe if you edit the services.json file, find the CapureService and change the VDIState value to "Unchanged", the will allow the CaptureService to start and Snip will work.

 

Note: I was unable to make it work AFTER it broke, but setting that value kept it from breaking after I rebuilt the session host and re-ran the optimize.

 

example:

 

{
"Name": "CaptureService",
"VDIState": "Unchanged",
"URL": "https://docs.microsoft.com/en-us/uwp/api/windows.graphics.capture?view=winrt-19041",
"Description": "OneCore capture service: enables optional screen capture functionality for applications that call the Windows.Graphics.Capture API."
}

 

Good luck

@Garthlogic 

 

You sir are a gent, that got Snip & Sketch working - sort of. Win + Shift + S now works and allows a screen capture, but there is no notification of the screen capture taken. So you can't click on it to open it in Snip & Sketch.

 

If I go in to Snip & Sketch and start a capture from there, that works and appear so it can be edited. There's another optimisation that is still in play that isn't allowing full functionality.

@Garthlogic 

 

I found out why it's not working - toast notifications are disabled in the LGPO phase of the optimisation:

 

skp574_0-1613736321355.png

 

If you set this back to not configured S&S works as expected.

Great! @skp574 

 

So did you get the S&S working within the optimization tool itself then?

 

g

Yes I did in the end. I parsed the user registry.pol out and edited this section:

User
Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications
NoToastApplicationNotification
DWORD:0

Changing DWORD value to 0 (was originally 1)

Used LGPO to create new registry.pol and the ran optimisation again and boom after restart S&S still worked.

@Christiaan_Brinkhoff   Please create a PowerShell Mgmt Pack for the Optimization Tool.  You could do the same thing instead of messing around with JSON without all of the complexity.  Think simplicity.

Hi everyone. Has anyone ran the script successfully from AIB? Or even from JasonofLondon json files? I keep getting failures on the script all the time.

@Christiaan_Brinkhoff 


Hi. Is there a way to perform a process to reverse the optimization process on a WVD host?

Unfortunately, not having the Windows Store apps has caused usability issues for a deployment. The users actually need Windows Calculator and the Windows Media player as an example.

Attempts for the user to reinstall the Windows Store app ends in unusual behavior where if the user installs Calculator as an example, it is not available for their current session. Once they logoff and logon again, the Store apps are no longer available and even a taskbar pin to the app no longer works. I assume this may be some Local policy or similar, but not sure where to start to check.

My initial thoughts were to reverse the entire process but not sure that is even possible?
Open to recommendations.

Thanks
Richard

 

Hi Richard

I hope this can help you a bit.

So I have been using this optimization Tool since it came out both for Azure Virtual Desktop and Windows 365. I have tried reverting once but gave up because many things were a mess. So I created my session host again (It was not a big deal since I'm using DevOps Automation.) and excluded the things in the optimization script I still needed.
Regarding the Windows Store app, if you are using FSLogix, the apps won't be there after the users log off and on again. Then they have to download it again. This is FSLogix specific issue.
https://techcommunity.microsoft.com/t5/azure-virtual-desktop/how-do-we-install-store-apps-the-proper...

@MortenPedholt 

 

Thanks so much for your reply. We considered recreating the WVD shared hosts but the amount of LOB apps already in the deployment is staggering. 

 

The link you sent regarding the Modern Windows apps and the FSLogix profile is certainly news to us. All our deployments use FSLogix and the fact that this wont work is amazing.  I just tested this in a secondary deployment and the Windows app (i.e. Calculator) definitely gets removed from the user after the install. 

 

I guess I need to find a way to install a regular Win32 calculator app or even the classic windows one if its available.

Hi Richard

Well, it sounds like you are configuring each session host manually? I always read my AVD machines from a Master/GoldenImage, or using Intune/SCCM.

There is also a difference if the Appx package is installed for one specific user or all users. You can perhaps try to do it the other way again. below is a snippet of how the script removes Appx packages. then do an Add instead of Remove if you know what I mean?

#region Begin Clean APPX Packages
<#
If (Test-Path .\ConfigurationFiles\AppxPackages.json)
{
$AppxPackage = Get-Content .\ConfigurationFiles\AppxPackages.json | ConvertFrom-Json
$AppxPackage = $AppxPackage | Where-Object { $_.VDIState -eq 'Disabled' }
}
If ($AppxPackage.Count -gt 0)
{
Foreach ($Item in $AppxPackage)
{
$Package = "*$($Item.AppxPackage)*"
Write-Verbose "Attempting to remove $($Item.AppxPackage) - $($Item.Description)"
Get-AppxPackage -Name $Package | Remove-AppxPackage -ErrorAction SilentlyContinue | Out-Null

Write-Verbose "Attempting to remove [All Users] $($Item.AppxPackage) - $($Item.Description)"
Get-AppxPackage -AllUsers -Name $Package | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue

Write-Verbose "Removing Provisioned Package $($item.AppxPackage)"
Get-AppxProvisionedPackage -Online | Where-Object { $_.PackageName -like $Package } | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue | Out-Null
}
}
#>
#endregion
Looking at using this on in our VDI that is running Server 2016 version 1607. Wanted to find out if this will work before attempting on a machine.