PowerShell: How to Reset Windows Update Service

# resetWindowsUpdateService
# This is a legacy method of reseting Windows Update
# Since most enterprises are having antiviruses nowadays, I've included an example of how to disable Palo Alto XDR Traps are a required to reset WuApp

$trapsBin='C:\Program Files\Palo Alto Networks\Traps'

function resetWindowsUpdateService{
		net stop wuauserv
		net stop cryptSvc
		net stop bits
		net stop msiserver
		mkdir C:\emptyDirectory
		md -Force C:\emptyDirectory
		Remove-Item "C:\emptyDirectory\*" -force -recurse -ErrorAction Continue
		robocopy C:\emptyDirectory C:\Windows\SoftwareDistribution /mir /R:0 /W:0 /NP
		robocopy C:\emptyDirectory C:\Windows\System32\catroot2 /mir /R:0 /W:0 /NP
		net start wuauserv
		net start cryptSvc
		net start bits
		net start msiserver
		return $true
		write-warning $_

function stopXdr{
		$trapsBin='C:\Program Files\Palo Alto Networks\Traps'
	echo $trapsAdminPassword | & "$trapsBin\cytool.exe" runtime stop

function startXdr{
		$trapsBin='C:\Program Files\Palo Alto Networks\Traps'
	echo $trapsAdminPassword | & "$trapsBin\cytool.exe" runtime start

stopXdr $trapsAdminPassword
startXdr $trapsAdminPassword
Posted on Categories Codes

Leave a Reply

Your email address will not be published. Required fields are marked *