Skip to content

Commit 1cf2e72

Browse files
authored
Merge pull request #46 from dsolodow/master
Plugin updates for Windows 11
2 parents bad3d45 + d5c007e commit 1cf2e72

File tree

3 files changed

+205
-0
lines changed

3 files changed

+205
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<#
2+
This program is free software: you can redistribute it and/or modify
3+
it under the terms of the GNU General Public License as published by
4+
the Free Software Foundation, either version 3 of the License, or
5+
(at your option) any later version.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
#>
15+
16+
<#
17+
.SYNOPSIS
18+
Decline updates for editions of Windows 11 your organization does not support.
19+
.DESCRIPTION
20+
Decline updates for editions of Windows 11 your organization does not support.
21+
.NOTES
22+
You must un-comment the $SupportedEditions variable and add the editions your organization supports.
23+
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.
24+
Written By: Damien Solodow
25+
Version 1.0: 01/15/2024
26+
#>
27+
28+
#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.
29+
#$SupportedEditions = @("Windows 11 \(business editions\),","Upgrade to Windows 11 \(business editions\)")
30+
31+
#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.
32+
$KnownEditions = @(
33+
'Upgrade to Windows 11 \(business editions\)',
34+
'Upgrade to Windows 11 \(consumer editions\)'
35+
'Windows 11 \(consumer editions\),'
36+
'Windows 11 \(business editions\),'
37+
)
38+
Function Invoke-SelectUpdatesPlugin{
39+
40+
$DeclineUpdates = @{}
41+
If (!$SupportedEditions){
42+
Return $DeclineUpdates
43+
}
44+
45+
46+
$Windows11Updates = $ActiveUpdates | Where-Object{$_.ProductTitles.Contains('Windows 11')}
47+
48+
#Loop through the updates and decline any that match the version.
49+
ForEach ($Update in $Windows11Updates){
50+
51+
#Verify that the title matches one of the known edition. If not then skip the update.
52+
$EditionFound = $False
53+
ForEach ($Edition in $KnownEditions){
54+
If ($Update.Title -match $Edition){
55+
$EditionFound = $True
56+
}
57+
}
58+
If(!$EditionFound){
59+
Continue
60+
} #Skip to the next update.
61+
62+
#Verify that the title does not match any of the editions the user supports.
63+
$EditionFound = $False
64+
ForEach ($Edition in $SupportedEditions){
65+
If ($Update.Title -match $Edition){
66+
$EditionFound = $True
67+
}
68+
}
69+
70+
#If one of the supported editions was found then skip to the next update.
71+
If($EditionFound -or (Test-Exclusions $Update)){
72+
Continue #Skip to the next update.
73+
} Else {
74+
$DeclineUpdates.Set_Item($Update.Id.UpdateId, 'Windows 11 Edition')
75+
}
76+
}
77+
Return $DeclineUpdates
78+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<#
2+
This program is free software: you can redistribute it and/or modify
3+
it under the terms of the GNU General Public License as published by
4+
the Free Software Foundation, either version 3 of the License, or
5+
(at your option) any later version.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
#>
15+
16+
<#
17+
.SYNOPSIS
18+
Decline Windows 11 updates based on language.
19+
.DESCRIPTION
20+
Decline Windows 11 updates for languages that are not selected to download software update files in the Software Update Point component.
21+
.NOTES
22+
If you are using stand-alone WSUS be sure to modify the SupportedUpdateLanguages variable to hard code the languages you support.
23+
Be sure to always include an 'all' element for language-independant updates.
24+
25+
26+
Written By: Damien Solodow
27+
Version 1.0: 01/15/2024
28+
#>
29+
30+
31+
Function Invoke-SelectUpdatesPlugin{
32+
33+
$DeclineUpdates = @{}
34+
35+
#Determine how to create the supported update language array.
36+
If ($StandAloneWSUS){
37+
$SupportedUpdateLanguages = @('en', 'all')
38+
} Else{
39+
#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.
40+
$SupportedUpdateLanguages = ((Get-CMSoftwareUpdatePointComponent).Props).Where({$_.PropertyName -eq 'SupportedUpdateLanguages'}).Value2
41+
If (!$SupportedUpdateLanguages){
42+
Return $DeclineUpdates
43+
}
44+
$SupportedUpdateLanguages = ($SupportedUpdateLanguages.ToLower() + ',all').Split(',')
45+
}
46+
47+
48+
#Get the Windows 11 updates.
49+
$Windows11Updates = $ActiveUpdates | Where-Object{($_.ProductTitles.Contains('Windows 11'))}
50+
51+
#Loop through the updates and decline any that don't support the defined languages.
52+
ForEach ($Update in $Windows11Updates){
53+
54+
#Loop through the updates's languages and determine if one of the defined languages is found.
55+
$LanguageFound = $False
56+
ForEach ($Language in $Update.GetSupportedUpdateLanguages()){
57+
If ($SupportedUpdateLanguages.Contains($Language)) {
58+
$LanguageFound = $True
59+
}
60+
}
61+
62+
#If none of the defined languages were found then decline the update.
63+
If (! $LanguageFound -and (! (Test-Exclusions $Update))){
64+
$DeclineUpdates.Set_Item($Update.Id.UpdateId, "Windows 11 Language: $($Update.GetSupportedUpdateLanguages())")
65+
}
66+
}
67+
Return $DeclineUpdates
68+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<#
2+
This program is free software: you can redistribute it and/or modify
3+
it under the terms of the GNU General Public License as published by
4+
the Free Software Foundation, either version 3 of the License, or
5+
(at your option) any later version.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
#>
15+
16+
<#
17+
.SYNOPSIS
18+
Decline updates for defined versions of Windows 11.
19+
.DESCRIPTION
20+
Decline updates for defined versions of Windows 11.
21+
.NOTES
22+
You must un-comment the $UnsupportedVersions variable and add the versions your organization does not support.
23+
Written By: Damien Solodow
24+
Version 1.0: 01/15/2024
25+
#>
26+
27+
#Un-comment and add elements to this array for versions you no longer support.
28+
#$UnsupportedVersions = @("22H2")
29+
Function Invoke-SelectUpdatesPlugin{
30+
31+
$DeclineUpdates = @{}
32+
If (!$UnsupportedVersions){
33+
Return $DeclineUpdates
34+
}
35+
36+
$Windows11Updates = ($ActiveUpdates | Where-Object{
37+
$_.ProductTitles.Contains('Windows 11')
38+
})
39+
40+
#Loop through the updates and decline any that match the version.
41+
ForEach ($Update in $Windows11Updates){
42+
43+
#If the title contains a version number.
44+
If (
45+
($Update.Title -match 'Version \d\d\d\d') -or ($Update.Title -match 'Version \d\d[Hh][1-2]') -and
46+
(! (Test-Exclusions $Update))
47+
){
48+
49+
#Capture the version number.
50+
$Version = $matches[0].Substring($matches[0].Length - 4)
51+
52+
#If the version number is in the list then decline it.
53+
If ($UnsupportedVersions.Contains($Version)){
54+
$DeclineUpdates.Set_Item($Update.Id.UpdateId, "Windows 11 Version: $($Version)")
55+
}
56+
}
57+
}
58+
Return $DeclineUpdates
59+
}

0 commit comments

Comments
 (0)