<# ******************************************************************************************************************************* Name: Reset-WindowsUpdate-WSUSManaged.ps1 Version: 0.1.0.0 (12/02/2021) Purpose: Resets Windows Update if device is managed by WSUS. Created by: Ashley How Pre-Reqs: PowerShell 2.0 Version History: 0.1.0.0 - Initial Release. ******************************************************************************************************************************* #> Try { If (-NOT (Test-Path -LiteralPath "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")){ Write-Output "Device is not managed by WSUS. No action required for Windows Update." $Check = $false Return } If ((Get-ItemPropertyValue -LiteralPath 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' -Name 'UseWUServer' -ea SilentlyContinue) -eq 1) { } Else { Write-Output "Device is not managed by WSUS. No action required for Windows Update." $Check = $false Return } } Catch { Write-Output "Device is not managed by WSUS. No action required for Windows Update." $Check = $false Return } $Check = $true If ($Check -eq $true) { Write-Output "Device is managed by WSUS. Resetting Windows Update back to default settings..." # Get Date $Date = Get-Date -Format dd.MM.yyyy # Stop the Windows Update service Stop-Service -Name wuauserv # Remove the registry key Rename-Item 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate' -NewName 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate.old($date)' -Force Remove-Item 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate' -Recurse -Force # Start the Windows Update service Start-Service -Name wuauserv }