From a1a22412cee3245d330e9f3d147b6285520601f9 Mon Sep 17 00:00:00 2001 From: iRaven4522 Date: Sat, 18 Oct 2025 17:11:58 -0500 Subject: [PATCH] UseWUServer force --- MDT-WinUpdate.ps1 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/MDT-WinUpdate.ps1 b/MDT-WinUpdate.ps1 index 9edd346..b6f81e9 100644 --- a/MDT-WinUpdate.ps1 +++ b/MDT-WinUpdate.ps1 @@ -23,10 +23,23 @@ $PSModulePathAU = $env:PSModulePath.split(';')[1] # All Users PSModule path if ($MDT){ $MDTPath = $Global:TSEnv.Value("DeployRoot") } -$WUServer = "http://fluttershy.technolog.net:8530" + +$WUServer = (Get-ItemProperty HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate).WUServer ## Functions +Function SetWUServer { + if (!(test-path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate)){ + New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" + } + New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name WUServer -Value "http://fluttershy.technolog.net:8530" + New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name WUStatusServer -Value "http://fluttershy.technolog.net:8530" + if (!(test-path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU)){ + New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" + } + New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name UseWUServer -Value 0 + +} Function ImportPSWindowsUpdate { Write-Host -ForegroundColor Yellow "Importing PS Windows Update module..." # Write-LogEntry -Value "Importing PS Windows Update Module..." -Severity 1 -Component "ImportPSWindowsUpdate" -FileName $ScriptLog @@ -137,6 +150,9 @@ Function Write-LogEntry # Main Program if ($MDT){ + if ($null -eq $WUServer) { + SetWUServer + } $ScriptLog = "$MDTPath\_Logs\$env:ComputerName-WindowsUpdate.log" } else { $ScriptLog = "$env:SystemDrive\irnh\PSWindowsUpdate.log"