Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
danycontre committed Nov 12, 2024
1 parent 2c96338 commit 8119835
Showing 1 changed file with 73 additions and 36 deletions.
109 changes: 73 additions & 36 deletions workload/scripts/Set-SessionHostConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,40 +83,77 @@ try {
# Run the Virtual Desktop Optimization Tool (VDOT)
##############################################################
# https://github.com/The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool
{
# Download VDOT
$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

# Extract VDOT from ZIP archive
Expand-Archive -LiteralPath $ZIP -Force

# Fix to disable AppX Packages
# As of 2/8/22, all AppX Packages are enabled by default
$Files = (Get-ChildItem -Path .\VDOT\Virtual-Desktop-Optimization-Tool-main -File -Recurse -Filter "AppxPackages.json").FullName
foreach ($File in $Files) {
$Content = Get-Content -Path $File
$Settings = $Content | ConvertFrom-Json
$NewSettings = @()
foreach ($Setting in $Settings) {
$NewSettings += [pscustomobject][ordered]@{
AppxPackage = $Setting.AppxPackage
VDIState = 'Disabled'
URL = $Setting.URL
Description = $Setting.Description
}
}
# Download VDOT
# $URL = 'https://github.com/The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool/archive/refs/heads/main.zip'
# $ZIP = 'VDOT.zip'
# Get-WebFile -FileName $ZIP -URL $URL

# # Extract VDOT from ZIP archive
# Expand-Archive -LiteralPath $ZIP -Force

# # Fix to disable AppX Packages
# # As of 2/8/22, all AppX Packages are enabled by default
# $Files = (Get-ChildItem -Path .\VDOT\Virtual-Desktop-Optimization-Tool-main -File -Recurse -Filter "AppxPackages.json").FullName
# foreach ($File in $Files) {
# $Content = Get-Content -Path $File
# $Settings = $Content | ConvertFrom-Json
# $NewSettings = @()
# foreach ($Setting in $Settings) {
# #Adds Exception to keep Windows ScreenSketch
# If ($Setting.AppxPackage -eq "Microsoft.ScreenSketch") {
# $NewSettings += [pscustomobject][ordered]@{
# AppxPackage = $Setting.AppxPackage
# VDIState = 'Unchanged'
# URL = $Setting.URL
# Description = $Setting.Description
# }
# }
# #Adds Exception to keep Windows Calculator
# ElseIf ($Setting.AppxPackage -eq "Microsoft.WindowsCalculator") {
# $NewSettings += [pscustomobject][ordered]@{
# AppxPackage = $Setting.AppxPackage
# VDIState = 'Unchanged'
# URL = $Setting.URL
# Description = $Setting.Description
# }
# }
# #Adds Exception to keep Windows Notepad
# ElseIf ($Setting.AppxPackage -eq "Microsoft.WindowsNotepad") {
# $NewSettings += [pscustomobject][ordered]@{
# AppxPackage = $Setting.AppxPackage
# VDIState = 'Unchanged'
# URL = $Setting.URL
# Description = $Setting.Description
# }
# }
# #Adds Exception to keep Windows Terminal
# ElseIf ($Setting.AppxPackage -eq "Microsoft.WindowsTerminal") {
# $NewSettings += [pscustomobject][ordered]@{
# AppxPackage = $Setting.AppxPackage
# VDIState = 'Unchanged'
# URL = $Setting.URL
# Description = $Setting.Description
# }
# }
# #Removes all other AppxPackages not listed above
# Else {
# $NewSettings += [pscustomobject][ordered]@{
# AppxPackage = $Setting.AppxPackage
# VDIState = 'Disabled'
# URL = $Setting.URL
# Description = $Setting.Description
# }
# }
# }

$JSON = $NewSettings | ConvertTo-Json
$JSON | Out-File -FilePath $File -Force
}
# $JSON = $NewSettings | ConvertTo-Json
# $JSON | Out-File -FilePath $File -Force
# }

# Run VDOT
& .\VDOT\Virtual-Desktop-Optimization-Tool-main\Windows_VDOT.ps1 -Optimizations 'All' -AdvancedOptimizations 'Edge', 'RemoveLegacyIE' -AcceptEULA
# # Run VDOT
# & .\VDOT\Virtual-Desktop-Optimization-Tool-main\Windows_VDOT.ps1 -Optimizations 'AppxPackages', 'Autologgers', 'DefaultUserSettings', 'LocalPolicy', 'NetworkOptimizations', 'ScheduledTasks', 'Services', 'WindowsMediaPlayer' -AdvancedOptimizations 'Edge', 'RemoveLegacyIE' -AcceptEULA

Write-Log -Message 'Optimized the operating system using VDOT' -Type 'INFO'
}
# Write-Log -Message 'Optimized the operating system using VDOT' -Type 'INFO'

##############################################################
# Add Recommended AVD Settings
Expand Down Expand Up @@ -423,8 +460,8 @@ try {
if ($IdentityServiceProvider -eq "EntraID" -and $AmdVmSize -eq 'false' -and $NvidiaVmSize -eq 'false') {
Start-Process -FilePath 'shutdown' -ArgumentList '/r /t 30'
}
}
catch {
Write-Log -Message $_ -Type 'ERROR'
throw
}
}
catch {
Write-Log -Message $_ -Type 'ERROR'
throw
}

0 comments on commit 8119835

Please sign in to comment.