diff --git a/images/win/scripts/Installers/Configure-GDIProcessHandleQuota.ps1 b/images/win/scripts/Installers/Configure-GDIProcessHandleQuota.ps1 new file mode 100644 index 000000000..8f1ab0d94 --- /dev/null +++ b/images/win/scripts/Installers/Configure-GDIProcessHandleQuota.ps1 @@ -0,0 +1,9 @@ +# https://docs.microsoft.com/en-us/windows/win32/sysinfo/gdi-objects +# This value can be set to a number between 256 and 65,536 + +$defaultValue = 20000 +Write-Host "Set the GDIProcessHandleQuota value to $defaultValue" +Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" -Name GDIProcessHandleQuota -Value $defaultValue +Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\Windows" -Name GDIProcessHandleQuota -Value $defaultValue + +Invoke-PesterTests -TestFile "WindowsFeatures" -TestName "GDIProcessHandleQuota" diff --git a/images/win/scripts/Tests/WindowsFeatures.Tests.ps1 b/images/win/scripts/Tests/WindowsFeatures.Tests.ps1 index f4c955e3a..96e453018 100644 --- a/images/win/scripts/Tests/WindowsFeatures.Tests.ps1 +++ b/images/win/scripts/Tests/WindowsFeatures.Tests.ps1 @@ -56,4 +56,13 @@ Describe "DynamicPorts" { $udpPorts | Should -BeNullOrEmpty } -} \ No newline at end of file +} + +Describe "GDIProcessHandleQuota" { + It "The GDIProcessHandleQuota value is 20000" { + $regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" + $regPath32 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\Windows" + (Get-ItemProperty $regPath).GDIProcessHandleQuota | Should -BeExactly 20000 + (Get-ItemProperty $regPath32).GDIProcessHandleQuota | Should -BeExactly 20000 + } +} diff --git a/images/win/windows2016.json b/images/win/windows2016.json index ad4876dd8..f090f12bc 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -329,6 +329,7 @@ "scripts": [ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1", "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1", + "{{ template_dir }}/scripts/Installers/Configure-GDIProcessHandleQuota.ps1", "{{ template_dir }}/scripts/Installers/Configure-Shell.ps1" ], "elevated_user": "{{user `install_user`}}", diff --git a/images/win/windows2019.json b/images/win/windows2019.json index 268bcce03..b98ea750e 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -322,6 +322,7 @@ "scripts": [ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1", "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1", + "{{ template_dir }}/scripts/Installers/Configure-GDIProcessHandleQuota.ps1", "{{ template_dir }}/scripts/Installers/Configure-Shell.ps1" ], "elevated_user": "{{user `install_user`}}",