|
| 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 | +} |
0 commit comments