关闭 Windows 更新服务 &使用PowerShell自动更新Windows 10 [英] Turn off windows update service & auto updates windows 10 using powershell

查看:36
本文介绍了关闭 Windows 更新服务 &使用PowerShell自动更新Windows 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 powershell 脚本来关闭 windows 更新服务 &使用PowerShell自动更新Windows 10.我四处搜索,但命令并没有完全关闭其中任何一个.

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 either one off completely.

我现在在不在网络上的设备上手动执行此操作,因此无法部署任何组策略:

I'm manually doing this now on devices that aren't on the network, so no group policy will be able to be deployed:

服务> Windows 更新> 禁用Windows 更新 > 更改设置 > 从不检查更新

services> windows update> disable Windows Update > Change Settings > Never Check for Updates

推荐答案

我找到了这个信息你可以试试

I found this information you can try it

Powershell

 Clear-Host

Write-Host "0 -> Change setting in Windows Update app (default)"
Write-Host "1 -> Never check for updates (not recommended)"
Write-Host "2 -> Notify for download and notify for install"
Write-Host "3 -> Auto download and notify for install"
Write-Host "4 -> Auto download and schedule the install"

Write-Host "Enter any character to exit"
Write-Host
switch(Read-Host "Choose Window Update Settings"){
       0 {$UpdateValue = 0}
       1 {$UpdateValue = 1}
       2 {$UpdateValue = 2}
       3 {$UpdateValue = 3}
       4 {$UpdateValue = 4}
       Default{Exit}
}

$WindowsUpdatePath = "HKLM:SOFTWAREPoliciesMicrosoftWindowsWindowsUpdate"
$AutoUpdatePath = "HKLM:SOFTWAREPoliciesMicrosoftWindowsWindowsUpdateAU"

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


If ($UpdateValue -gt 0) {
    New-Item -Path $WindowsUpdatePath
    New-Item -Path $AutoUpdatePath
}

If ($UpdateValue -eq 1) {
    Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 1
}

If ($UpdateValue -eq 2) {
    Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 0
    Set-ItemProperty -Path $AutoUpdatePath -Name AUOptions -Value 2
    Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallDay -Value 0
    Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallTime -Value 3
}

If ($UpdateValue -eq 3) {
    Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 0
    Set-ItemProperty -Path $AutoUpdatePath -Name AUOptions -Value 3
    Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallDay -Value 0
    Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallTime -Value 3
}

If ($UpdateValue -eq 4) {
    Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 0
    Set-ItemProperty -Path $AutoUpdatePath -Name AUOptions -Value 4
    Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallDay -Value 0
    Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallTime -Value 3
}

这篇关于关闭 Windows 更新服务 &使用PowerShell自动更新Windows 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆