Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Automatic Updates with PowerShell

I would like to know how to disable Automatic Updates with PowerShell on a windows machine.

Thanks in advance!

like image 398
LP. Avatar asked Apr 15 '11 20:04

LP.


People also ask

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.

How do I stop the Windows Update service in PowerShell?

2: Stop Windows Update Service by PID Press CTRL+ALT+DEL and click on Task Manager. Click on the Services tab. Find wuauserv and make note of the PID. Now open the Command Prompt or PowerShell as Admin and type in taskkill /f /pid **** where **** is your PID.


1 Answers

Here's a couple functions to set and get Windows Update configurations

$SCRIPT:AutoUpdateNotificationLevels= @{   

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

}

$SCRIPT:AutoUpdateDays=@{
0="Every Day"; 
1="Every Sunday"; 
2="Every Monday"; 
3="Every Tuesday"; 
4="Every Wednesday";
5="Every Thursday"; 
6="Every Friday"; 
7="Every Saturday"
}


Function Get-WindowsUpdateConfig
{
    $AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
    $AUObj = New-Object -TypeName System.Object

    Add-Member -inputObject $AuObj -MemberType NoteProperty -Name "NotificationLevel"  `
               -Value $AutoUpdateNotificationLevels[$AUSettings.NotificationLevel]

    Add-Member -inputObject $AuObj -MemberType NoteProperty -Name "UpdateDays" `
               -Value $AutoUpdateDays[$AUSettings.ScheduledInstallationDay]

    Add-Member -inputObject $AuObj -MemberType NoteProperty -Name "UpdateHour"   `
               -Value $AUSettings.ScheduledInstallationTime 

    Add-Member -inputObject $AuObj -MemberType NoteProperty -Name "Recommended updates" `
               -Value $(IF ($AUSettings.IncludeRecommendedUpdates) {"Included"}  else {"Excluded"})
    $AuObj
 } 

Function Set-WindowsUpdateConfig
{
Param (

[Parameter()]
[ValidateRange(0,4)]
[int]
$NotificationLevel , 

[Parameter()]
[ValidateRange(0,7)]
[int]
$Day, 

[Parameter()]
[ValidateRange(0,24)]
[int]
$hour, 

[Parameter()]
[bool]
$IncludeRecommended
)

 $AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
 if ($NotificationLevel)  {$AUSettings.NotificationLevel        =$NotificationLevel}
 if ($Day)                {$AUSettings.ScheduledInstallationDay =$Day}
 if ($hour)               {$AUSettings.ScheduledInstallationTime=$hour}
 if ($IncludeRecommended) {$AUSettings.IncludeRecommendedUpdates=$IncludeRecommended}
 $AUSettings.Save()
} 
like image 129
Andy Schneider Avatar answered Sep 20 '22 10:09

Andy Schneider