Skip to content

Plugin updates for Windows 11 #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<#
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
#>

<#
.SYNOPSIS
Decline updates for editions of Windows 11 your organization does not support.
.DESCRIPTION
Decline updates for editions of Windows 11 your organization does not support.
.NOTES
You must un-comment the $SupportedEditions variable and add the editions your organization supports.
The KnownEditions variable holds a list of known editions to _try_ and prevent the script from going rogue if MS decides to change the naming scheme. If ... or when ... they do this will need to be updated.
Written By: Damien Solodow
Version 1.0: 01/15/2024
#>

#Un-comment and add elements to this array for editions you support. Be sure to add a comma at the end in order to avoid confusion between editions.
#$SupportedEditions = @("Windows 11 \(business editions\),","Upgrade to Windows 11 \(business editions\)")

#If Microsoft decides to change their naming scheme you will need to update this variable to support the new scheme. Note that commas are used to prevent mismatches.
$KnownEditions = @(
'Upgrade to Windows 11 \(business editions\)',
'Upgrade to Windows 11 \(consumer editions\)'
'Windows 11 \(consumer editions\),'
'Windows 11 \(business editions\),'
)
Function Invoke-SelectUpdatesPlugin{

$DeclineUpdates = @{}
If (!$SupportedEditions){
Return $DeclineUpdates
}


$Windows11Updates = $ActiveUpdates | Where-Object{$_.ProductTitles.Contains('Windows 11')}

#Loop through the updates and decline any that match the version.
ForEach ($Update in $Windows11Updates){

#Verify that the title matches one of the known edition. If not then skip the update.
$EditionFound = $False
ForEach ($Edition in $KnownEditions){
If ($Update.Title -match $Edition){
$EditionFound = $True
}
}
If(!$EditionFound){
Continue
} #Skip to the next update.

#Verify that the title does not match any of the editions the user supports.
$EditionFound = $False
ForEach ($Edition in $SupportedEditions){
If ($Update.Title -match $Edition){
$EditionFound = $True
}
}

#If one of the supported editions was found then skip to the next update.
If($EditionFound -or (Test-Exclusions $Update)){
Continue #Skip to the next update.
} Else {
$DeclineUpdates.Set_Item($Update.Id.UpdateId, 'Windows 11 Edition')
}
}
Return $DeclineUpdates
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<#
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
#>

<#
.SYNOPSIS
Decline Windows 11 updates based on language.
.DESCRIPTION
Decline Windows 11 updates for languages that are not selected to download software update files in the Software Update Point component.
.NOTES
If you are using stand-alone WSUS be sure to modify the SupportedUpdateLanguages variable to hard code the languages you support.
Be sure to always include an 'all' element for language-independant updates.


Written By: Damien Solodow
Version 1.0: 01/15/2024
#>


Function Invoke-SelectUpdatesPlugin{

$DeclineUpdates = @{}

#Determine how to create the supported update language array.
If ($StandAloneWSUS){
$SupportedUpdateLanguages = @('en', 'all')
} Else{
#Get the supported languages from the SUP component, exiting if it's not found, then add the 'all' language, and split them into an array.
$SupportedUpdateLanguages = ((Get-CMSoftwareUpdatePointComponent).Props).Where({$_.PropertyName -eq 'SupportedUpdateLanguages'}).Value2
If (!$SupportedUpdateLanguages){
Return $DeclineUpdates
}
$SupportedUpdateLanguages = ($SupportedUpdateLanguages.ToLower() + ',all').Split(',')
}


#Get the Windows 11 updates.
$Windows11Updates = $ActiveUpdates | Where-Object{($_.ProductTitles.Contains('Windows 11'))}

#Loop through the updates and decline any that don't support the defined languages.
ForEach ($Update in $Windows11Updates){

#Loop through the updates's languages and determine if one of the defined languages is found.
$LanguageFound = $False
ForEach ($Language in $Update.GetSupportedUpdateLanguages()){
If ($SupportedUpdateLanguages.Contains($Language)) {
$LanguageFound = $True
}
}

#If none of the defined languages were found then decline the update.
If (! $LanguageFound -and (! (Test-Exclusions $Update))){
$DeclineUpdates.Set_Item($Update.Id.UpdateId, "Windows 11 Language: $($Update.GetSupportedUpdateLanguages())")
}
}
Return $DeclineUpdates
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<#
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
#>

<#
.SYNOPSIS
Decline updates for defined versions of Windows 11.
.DESCRIPTION
Decline updates for defined versions of Windows 11.
.NOTES
You must un-comment the $UnsupportedVersions variable and add the versions your organization does not support.
Written By: Damien Solodow
Version 1.0: 01/15/2024
#>

#Un-comment and add elements to this array for versions you no longer support.
#$UnsupportedVersions = @("22H2")
Function Invoke-SelectUpdatesPlugin{

$DeclineUpdates = @{}
If (!$UnsupportedVersions){
Return $DeclineUpdates
}

$Windows11Updates = ($ActiveUpdates | Where-Object{
$_.ProductTitles.Contains('Windows 11')
})

#Loop through the updates and decline any that match the version.
ForEach ($Update in $Windows11Updates){

#If the title contains a version number.
If (
($Update.Title -match 'Version \d\d\d\d') -or ($Update.Title -match 'Version \d\d[Hh][1-2]') -and
(! (Test-Exclusions $Update))
){

#Capture the version number.
$Version = $matches[0].Substring($matches[0].Length - 4)

#If the version number is in the list then decline it.
If ($UnsupportedVersions.Contains($Version)){
$DeclineUpdates.Set_Item($Update.Id.UpdateId, "Windows 11 Version: $($Version)")
}
}
}
Return $DeclineUpdates
}