UseWUServer force

This commit is contained in:
2025-10-18 17:11:58 -05:00
parent 6562e8d36b
commit a1a22412ce

View File

@@ -23,10 +23,23 @@ $PSModulePathAU = $env:PSModulePath.split(';')[1] # All Users PSModule path
if ($MDT){ if ($MDT){
$MDTPath = $Global:TSEnv.Value("DeployRoot") $MDTPath = $Global:TSEnv.Value("DeployRoot")
} }
$WUServer = "http://fluttershy.technolog.net:8530"
$WUServer = (Get-ItemProperty HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate).WUServer
## Functions ## 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 { Function ImportPSWindowsUpdate {
Write-Host -ForegroundColor Yellow "Importing PS Windows Update module..." Write-Host -ForegroundColor Yellow "Importing PS Windows Update module..."
# Write-LogEntry -Value "Importing PS Windows Update Module..." -Severity 1 -Component "ImportPSWindowsUpdate" -FileName $ScriptLog # Write-LogEntry -Value "Importing PS Windows Update Module..." -Severity 1 -Component "ImportPSWindowsUpdate" -FileName $ScriptLog
@@ -137,6 +150,9 @@ Function Write-LogEntry
# Main Program # Main Program
if ($MDT){ if ($MDT){
if ($null -eq $WUServer) {
SetWUServer
}
$ScriptLog = "$MDTPath\_Logs\$env:ComputerName-WindowsUpdate.log" $ScriptLog = "$MDTPath\_Logs\$env:ComputerName-WindowsUpdate.log"
} else { } else {
$ScriptLog = "$env:SystemDrive\irnh\PSWindowsUpdate.log" $ScriptLog = "$env:SystemDrive\irnh\PSWindowsUpdate.log"