Turn off windows update service & auto updates windows 10 using powershell

前端 未结 6 1970
难免孤独
难免孤独 2020-12-17 04:58

I want to use a powershell script to turn off windows update service & auto updates windows 10 using powershell. I\'ve searched around but the commands didn\'t turn eit

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-17 05:30

    EDIT 2020-07-30:

    The former solution, which is bellow, works only partially: it does not disable the WindowsUpdate/sihpostreboot service, because Microsoft is fighting against guides like this.

    WHAT WORKS FULLY: (how to disable the rest)

    • follow the steps of the original solution bellow (will finish with few errors)
    • download and unzip Microsoft PSTools
    • start the command line as Administrator in location with psexec.exe
    • start the Task Scheduler with the SYSTEM permissions: psexec -i -d -s mmc taskschd.msc
    • disable the rest of not disabled update tasks manually


    THE ORIGINAL ANSWER:

    This script is based on Kemal's answer.

    The improvement is that it disables also tasks in WindowsUpdate and UpdateOrchestrator folders that cannot be disabled manually in Task Scheduler. Furthermore, it disables the Windows Update service.

    Recommended execution:

    1. Install all pending updates so that you are in "Your device is up to date" state.
    2. Run the following PowerShell script as an Administrator:
        Clear-Host
    
        $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
    
        # We disable WindowsUpdate folder again, because wuauserv service could have enabled it meanwhile
        Get-ScheduledTask -TaskPath "\Microsoft\Windows\WindowsUpdate\" | Disable-ScheduledTask
    
        Write-Output "All Windows Updates were disabled"
    

    Note: the script may display execution errors if WindowsUpdate folder or UpdateOrchestrator folder does not exist.

    Note 2: you may need to run the script again after some Microsoft installer runs (like .Net Framework installer, Visual Studio installer, ...), because they enable updates again.

提交回复
热议问题