简体   繁体   English

如何将Windows Update设置为从不使用PowerShell检查更新?

[英]How do I set Windows Update to never check for updates with PowerShell?

I'm looking for help scripting with PowerShell, Windows Server 2008 R2 so Windows Updates is set to "Never check for updates." 我正在寻找PowerShell,Windows Server 2008 R2的帮助脚本,因此Windows更新设置为“从不检查更新”。 I found some near answers but I still can't do what I want. 我找到了一些接近的答案,但我仍然不能做我想要的。 Currently, I have to set it by clicking Windows Update > Change Settings > Never Check for Updates. 目前,我必须通过单击Windows Update>更改设置>从不检查更新来设置它。 Thanks in advance. 提前致谢。

You can use a COM object for that : 您可以使用COM对象:

$WUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
$WUSettings
NotificationLevel         : 2
ReadOnly                  : True
Required                  : False
ScheduledInstallationDay  : 0
ScheduledInstallationTime : 3
IncludeRecommendedUpdates : True
NonAdministratorsElevated : True
FeaturedUpdatesEnabled    : True

With : 用:

NotificationLevel  :
0 = Not configured;
1 = Disabled;
2 = Notify before download;
3 = Notify before installation;
4 = Scheduled installation;

You can test : 你可以测试:

$WUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
$WUSettings.NotificationLevel=1
$WUSettings.save()

(Edited) (编辑)的

You must use a PowerShell session run as administrator in an elevated mode. 您必须在提升模式下以管理员身份运行PowerShell会话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM