Skip to content

Conversation

Copy link

Copilot AI commented Oct 16, 2025

Problem

The Optimize_OS_for_AVD.ps1 script was broken due to breaking changes in the upstream Virtual-Desktop-Optimization-Tool repository:

  1. The legacy script Win10_VirtualDesktop_Optimize.ps1 no longer exists in the VDOT repository
  2. The current script Windows_VDOT.ps1 now requires a mandatory -Optimizations parameter (see VDOT documentation)
  3. The script was redundantly downloading Windows_VDOT.ps1 separately when it's already included in the downloaded zip archive

These issues caused VM image builds to fail, with VMs stuck in 'creating' state and eventually timing out.

Changes

This PR makes minimal, surgical changes to fix the compatibility issues:

1. Removed redundant script download (lines 20-22)

-# instrumentation
-$osOptURL = 'https://raw.githubusercontent.com/The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool/main/Windows_VDOT.ps1'
-$osOptURLexe = 'optimize.ps1'
-Invoke-WebRequest -Uri $osOptURL -OutFile $osOptURLexe

The script is already included in the zip archive, making this download unnecessary.

2. Removed references to deprecated Win10_VirtualDesktop_Optimize.ps1

-# Patch: override the Win10_VirtualDesktop_Optimize.ps1 - setting 'Set-NetAdapterAdvancedProperty'(see readme.md)
-Write-Host 'Patch: Disabling Set-NetAdapterAdvancedProperty'
-$updatePath = 'C:\optimize\Virtual-Desktop-Optimization-Tool-main\Win10_VirtualDesktop_Optimize.ps1'
- ((Get-Content -Path $updatePath -Raw) -replace 'Set-NetAdapterAdvancedProperty -DisplayName "Send Buffer Size" -DisplayValue 4MB', '#Set-NetAdapterAdvancedProperty -DisplayName "Send Buffer Size" -DisplayValue 4MB') | Set-Content -Path $updatePath

This script no longer exists in the VDOT repository.

3. Added mandatory -Optimizations parameter and simplified execution

-# run script
-# .\optimize -WindowsVersion 2004 -Verbose
-.\Win10_VirtualDesktop_Optimize.ps1 -Verbose -AcceptEULA
-Write-Host 'AIB Customization: Finished OS Optimizations script Win10_VirtualDesktop_Optimize.ps1'
-
-# Sleep for a min
-Start-Sleep -Seconds 60
-#Running new file
-
-#Write-Host 'Running new AIB Customization script'
-.\Windows_VDOT.ps1 -Verbose -AcceptEULA
-
-Write-Host 'AIB Customization: Finished OS Optimizations script Windows_VDOT.ps1'
+# run script
+.\Windows_VDOT.ps1 -Optimizations All -Verbose -AcceptEULA
+Write-Host 'AIB Customization: Finished OS Optimizations script'

The script now runs Windows_VDOT.ps1 once with the mandatory -Optimizations All parameter instead of attempting to run both old and new scripts.

4. Fixed path casing consistency

-$updatePath = 'C:\optimize\Virtual-Desktop-Optimization-Tool-main\Windows_VDOT.ps1'
+$updatePath = 'C:\Optimize\Virtual-Desktop-Optimization-Tool-main\Windows_VDOT.ps1'

Ensured consistent casing with other hardcoded paths in the script.

Testing

  • ✅ PowerShell syntax validation passed
  • ✅ Verified script structure matches current VDOT repository layout
  • ✅ Confirmed -Optimizations All parameter matches VDOT documentation requirements

Impact

The script now correctly works with the latest version of the Virtual-Desktop-Optimization-Tool repository and should resolve VM image build failures.

Fixes #844

Original prompt

This section details on the original issue you should resolve

<issue_title>Optimize_OS_for_AVD.ps1 Issues</issue_title>
<issue_description>### What happened? Provide a clear and concise description of the bug, including deployment details.

Hi,

Recently came across the following issues with this script:

  • It downloads artifacts from another repo (The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool), but because it doesn't pin versions, subsequent commands are broken. Zip file downloaded here and a script here (I think downloading the script individually is redundant because it exists in the zip download)
  • Due to the above, it is referencing the now non-existent 'Win10_VirtualDesktopOptimize.ps1' here and here
  • It does not include the now-mandatory parameter 'Optimizations'

The changes to the Virtual-Desktop-Optimization-Tool repo are below in case it's useful:

The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool@76a1532

The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool@8a9d527

Please provide the correlation id associated with your error or bug.

N/A

What was the expected outcome?

Script to complete without errors. I found this issue after isolating the cause of a broken VM image version to this script (image template build completed and uploaded the image to our gallery successfully but then VM deployment failed - VM stuck on 'creating' then timed out).

Relevant log output

```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@danycontre</author><body>
@mikejwhat thanks for submitting the issue, we are reviewing.

@swathibhat1 @jamasten </body></comment_new>
</comments>

Fixes #817


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Fix version pinning in Optimize_OS_for_AVD.ps1 Fix Optimize_OS_for_AVD.ps1 compatibility with updated Virtual-Desktop-Optimization-Tool repository Oct 16, 2025
Copilot AI requested a review from danycontre October 16, 2025 13:06
Copilot finished work on behalf of danycontre October 16, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize_OS_for_AVD.ps1 Issues

2 participants