From 8ef12596d91283d6dd73b9a33b06f951ec78b463 Mon Sep 17 00:00:00 2001 From: awarre <30052685+awarre@users.noreply.github.com> Date: Mon, 3 Aug 2020 08:47:59 -0400 Subject: [PATCH] Update Optimize-WsusServer.ps1 Added Breaks to escape switch statements after successful evaluation. --- Optimize-WsusServer.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Optimize-WsusServer.ps1 b/Optimize-WsusServer.ps1 index e8f34b1..de960b7 100644 --- a/Optimize-WsusServer.ps1 +++ b/Optimize-WsusServer.ps1 @@ -476,10 +476,12 @@ function New-WsusMaintainenceTask($interval) { 'Daily' { $trigger = New-ScheduledTaskTrigger -Daily -At "12pm" $scriptAction = "-OptimizeServer" + Break } 'Weekly' { $trigger = New-ScheduledTaskTrigger -Weekly -At "2am" -DaysOfWeek Sunday $scriptAction = "-OptimizeDatabase" + Break } Default {} } @@ -649,6 +651,7 @@ function Update-WsusIISConfig ($settingKey, $recommendedValue) { 'QueueLength' { # Queue Length Set-IISConfigAttributeValue -ConfigElement $wsusPoolConfig -AttributeName "queueLength" -AttributeValue $recommendedValue + Break } 'LoadBalancerCapabilities' { # Failure Config Root @@ -656,24 +659,29 @@ function Update-WsusIISConfig ($settingKey, $recommendedValue) { # Load Balancer Capabilities Set-IISConfigAttributeValue -ConfigElement $wsusPoolFailureConfig -AttributeName "loadBalancerCapabilities" -AttributeValue $recommendedValue + Break } 'CpuResetInterval' { # CPU Reset Interval $wsusPoolCpuConfig = Get-IISConfigElement -ConfigElement $wsusPoolConfig -ChildElementName "cpu" Set-IISConfigAttributeValue -ConfigElement $wsusPoolCpuConfig -AttributeName "resetInterval" -AttributeValue ([timespan]::FromMinutes($recommendedValue)) + Break } 'RecyclingMemory' { Set-IISConfigAttributeValue -ConfigElement $wsusPoolRecyclingConfig -AttributeName "memory" -AttributeValue $recommendedValue - + Break } 'RecyclingPrivateMemory' { Set-IISConfigAttributeValue -ConfigElement $wsusPoolRecyclingConfig -AttributeName "privateMemory" -AttributeValue $recommendedValue + Break } 'ClientMaxRequestLength' { Set-WebConfigurationProperty -PSPath 'IIS:\Sites\WSUS Administration\ClientWebService' -Filter "system.web/httpRuntime" -Name "maxRequestLength" -Value $recommendedValue + Break } 'ClientExecutionTimeout' { Set-WebConfigurationProperty -PSPath 'IIS:\Sites\WSUS Administration\ClientWebService' -Filter "system.web/httpRuntime" -Name "executionTimeout" -Value ([timespan]::FromSeconds($recommendedValue)) + Break } Default {} }