【问题标题】:Programmatically Disable-ScheduledTask For Windows Update on Build 16299在 Build 16299 上以编程方式禁用 Windows 更新的计划任务
【发布时间】:2018-08-07 12:53:21
【问题描述】:

我正在尝试解决脚本问题。

在以前的 Windows 10 版本中,我已经能够使用以下脚本来禁用 Windows 10 更新:

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

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

stop-service wuauserv

在 Build 16299 上尝试更新此内容时,禁用命令失败,并出现以下异常:

Get-ScheduledTask : 系统找不到指定的文件。 + CategoryInfo : ObjectNotFound: (MSFT_ScheduledTask:Root/Microsoft/...T_ScheduledTask) [Get-ScheduledTas k],CimException + FullyQualifiedErrorId : HRESULT 0x80070002,Get-ScheduledTask

我发现的一个解决方法是使用PSExec打开TaskScheduler:

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

但是,这需要手动禁用每个文件夹中的 13 项服务。

我的下一个想法是将两者结合到一个 .net 应用程序中,但我想知道是否有人修复了 powershell 命令。我假设 Windows 现在正在为任务路径使用某种类型的别名?

感谢任何帮助。

【问题讨论】:

    标签: windows powershell


    【解决方案1】:

    试试下面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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-22
      • 2010-10-03
      • 2019-02-18
      • 1970-01-01
      • 2014-04-20
      • 1970-01-01
      • 2015-10-30
      • 2010-09-22
      相关资源
      最近更新 更多