Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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." 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. Thanks in advance.

like image 268
user1256194 Avatar asked Mar 08 '12 03:03

user1256194


People also ask

How do I stop the Windows Update service in PowerShell?

Open Start. Search for PowerShell, right-click the top result, and select the Run as administrator option. Type the following command to disable a service and press Enter: Set-Service -Name "SERVICE-NAME" -Status stopped -StartupType disabled In the command, update "SERVICE-NAME" for the name of the service.

How do I permanently disable the Windows 10 update PowerShell?

Disabling the Windows Update service Then, type “services” in the Windows 10 search box and click View Local Services. Scroll down to Windows Update and double-click the service. Set the startup type to Disabled. If the service is already running, click Stop.


1 Answers

You can use a COM object for that :

$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.

like image 58
JPBlanc Avatar answered Oct 01 '22 16:10

JPBlanc