Programmatically Disable-ScheduledTask For Windows Update on Build 16299

0

I'm trying to troubleshoot an issue with a script.

On previous build of windows 10 I have been able to use the following script to disable windows 10 Updates:

Get-ScheduledTask -TaskPath "\Microsoft\Windows\WindowsUpdate\" | Disable-ScheduledTask 

Get-ScheduledTask -TaskPath "\Microsoft\Windows\UpdateOrchestrator\" | Disable-ScheduledTask 

stop-service wuauserv

Upon trying to update this on Build 16299 the disable commands fail with the following exception:

Get-ScheduledTask : The system cannot find the file specified. + CategoryInfo : ObjectNotFound: (MSFT_ScheduledTask:Root/Microsoft/...T_ScheduledTask) [Get-ScheduledTas k], CimException + FullyQualifiedErrorId : HRESULT 0x80070002,Get-ScheduledTask

A work around I found is to use PSExec to open the TaskScheduler:

psexec.exe -i -s -accepteula %windir%\system32\mmc.exe /s taskschd.msc

However this requires manually disabling each of the 13 services in each folder.

My next thought would be to combine the two into a .net app but I was wondering if anyone has a fix for the powershell commands. I'm assuming windows is now using some type of alias for the the task paths ?

Any help is appreciated.

windows
powershell
asked on Stack Overflow Feb 27, 2018 by bumble_bee_tuna

1 Answer

2

Try the following PowerShell script

#Disable Windows Update
$WindowsUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\"
$AutoUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"

If(Test-Path -Path $WindowsUpdatePath) {
    Remove-Item -Path $WindowsUpdatePath -Recurse
}

New-Item $WindowsUpdatePath -Force
New-Item $AutoUpdatePath -Force

Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 1

Get-ScheduledTask -TaskPath "\Microsoft\Windows\WindowsUpdate\" | Disable-ScheduledTask

takeown /F C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator /A /R
icacls C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator /grant Administrators:F /T

Get-ScheduledTask -TaskPath "\Microsoft\Windows\UpdateOrchestrator\" | Disable-ScheduledTask

Stop-Service wuauserv
Set-Service wuauserv -StartupType Disabled

Write-Output "All Windows Updates were disabled" -ForegroundColor Green
answered on Stack Overflow May 23, 2018 by vmoskalenko

User contributions licensed under CC BY-SA 3.0