Skip to content

Instantly share code, notes, and snippets.

@nanoDBA
Last active August 31, 2022 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanoDBA/6dc0974d4ea7e275b5fb40df6cb6b545 to your computer and use it in GitHub Desktop.
Save nanoDBA/6dc0974d4ea7e275b5fb40df6cb6b545 to your computer and use it in GitHub Desktop.
Exclude SQL Server From Windows Updates
<# DANGER - ***forced reboot(s) may occur*** #>
# $moduleName = "PSWindowsUpdate"
# if (Get-Module -ListAvailable -Name $moduleName) {
# Write-Output "$moduleName module is already installed." | Out-String | Write-Host -ForegroundColor Yellow
# Import-Module $moduleName
# }
# else {
# Write-Output "Module $moduleName is not installed - installing..." | Out-String | Write-Host -ForegroundColor Yellow
# $NuGetProvider = Get-PackageProvider -Name NuGet | Where-Object Version -GT 2.8.5.201; if ( -not $NuGetProvider) { Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$false }
# <# Install moduleName #>Install-Module -Force $moduleName -Confirm:$false -Verbose
# Import-Module $moduleName
# }
<# DANGER - ***forced reboot(s) may occur*** #>
$paramHash = @{
AcceptAll = $True
Install = $True
NotTitle = 'SQL' <# Exclude SQL Server From Windows Updates #>
Verbose = $True
# Modify next line as desired
RootCategories = 'Security Updates','Critical Updates', 'Definition Updates' #, 'Drivers'
AutoReboot = $True
# AutoReboot = $false
Confirm = $True
}
Get-WindowsUpdate @paramHash -ShowPreSearchCriteria -MicrosoftUpdate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment