Problem:
Prior to February 2022, the Virtual Desktop Optimization Tool (VDOT) would allow you to disable Appx packages by setting the “Optimizations” parameter to either “All” or including “AppxPackages” in the string array. Customer feedback forced the team to change the tool to enable these packages by default, complicating the automation of the tool. Now all the Appx packages in the JSON file are set to “Unchanged” or “Enabled” so that all the unneeded applications are included by default unless the Appx Package JSON file is updated.
Solution:
Use my code below to download VDOT, update all the Appx packages to “Disabled”, and run the tool on your Azure Virtual Desktop session hosts:
$URL = 'https://github.com/The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool/archive/refs/heads/main.zip'
$ZIP = 'VDOT.zip'
Invoke-WebRequest -Uri $URL -OutFile $ZIP -ErrorAction 'Stop'
Expand-Archive -LiteralPath $ZIP -Force -ErrorAction 'Stop'
$Files = (Get-ChildItem -Path .\VDOT\Virtual-Desktop-Optimization-Tool-main -File -Recurse -Filter "AppxPackages.json" -ErrorAction 'Stop').FullName
foreach($File in $Files)
{
$Content = Get-Content -Path $File -ErrorAction 'Stop'
$Settings = $Content | ConvertFrom-Json -ErrorAction 'Stop'
$NewSettings =@()
foreach($Setting in $Settings)
{
$NewSettings += [pscustomobject][ordered]@{
AppxPackage = $Setting.AppxPackage
VDIState = 'Disabled'
URL = $Setting.URL
Description = $Setting.Description
}
}
$JSON = $NewSettings | ConvertTo-Json -ErrorAction 'Stop'
$JSON | Out-File -FilePath $File -Force -ErrorAction 'Stop'
}
& .\VDOT\Virtual-Desktop-Optimization-Tool-main\Windows_VDOT.ps1 -AcceptEULA -Restart
Explanation:
In most scenarios, myself or my customers do not need any of the applications in the Appx Packages JSON file. Since the state of the Appx Packages are no longer set to “Disabled”, the code above will loop through and correct the configuration. The code corrects all the Appx Package JSON files for every version of Windows by importing the JSON, converting it to PowerShell, updating the “VDIState” to “Disabled” for each Appx Package, and overwriting the JSON files with the updated configurations. This is important because the code above is deployed in Azure using the Custom Script Extension on each session host and prevents any manual intervention.