Skip to content

Commit 8a96f5c

Browse files
amr952Andrew RibeiroTraGicCode
authored
(GH-47) wsus-config-update-products: Fixes Duplicate Product Name Selection (#48)
* Added For Loop to select all products that match - Removed unique from compare * Fixed detection script - wsus-config-update-products * Formatting fix * Testing Update from other member Co-authored-by: Andrew Ribeiro <[email protected]> Co-authored-by: Michael Fyffe <[email protected]>
1 parent b48037d commit 8a96f5c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

manifests/approvalrule.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
onlyif => "\$ErrorActionPreference = \"Stop\"
7777
\$wsus = Get-WsusServer
7878
\$approvalRule = \$wsus.GetInstallApprovalRules() | Where-Object { \$PSItem.Name -eq \"${rule_name}\" }
79-
\$currentApprovalCategories = \$approvalRule.GetCategories() | Select-Object -ExpandProperty Title
79+
\$currentApprovalCategories = \$approvalRule.GetCategories() | Select-Object -ExpandProperty Title -Unique
8080
if(\$currentApprovalCategories -eq \$null)
8181
{
8282
\$currentApprovalCategories = \"\"

manifests/config.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@
387387
}
388388
else {
389389
# product title is valid. add it to the new collection
390-
[void]\$NewProducts.add( (\$allPossibleProducts | Where-Object {\$_.Title -eq \$product -and \$_.type -eq \$Type} | Select-Object -First 1) )
390+
[void]\$NewProducts.addRange( (\$allPossibleProducts | Where-Object {\$_.Title -eq \$product -and \$_.type -eq \$Type}) )
391391
}
392392
}
393393
}
@@ -510,10 +510,10 @@
510510
\$desired_productfamilies = \$commaSeparatedProductFamilies.Split(\";\")
511511
}
512512
# get current enabled product families, blank array if none
513-
\$currentEnabledProductFamilies = (\$wsusServerSubscription.GetUpdateCategories() | Where-Object {\$_.type -eq \"productfamily\"}).Title
513+
\$currentEnabledProductFamilies = (\$wsusServerSubscription.GetUpdateCategories() | Where-Object {\$_.type -eq \"productfamily\"}).Title | Select-Object -Unique
514514
if (\$null -eq \$currentEnabledProductFamilies) { \$currentEnabledProductFamilies = @('') }
515515
# get current enabled products, blank array if none
516-
\$currentEnabledProducts = (\$wsusServerSubscription.GetUpdateCategories() | Where-Object {\$_.type -eq \"product\"}).Title
516+
\$currentEnabledProducts = (\$wsusServerSubscription.GetUpdateCategories() | Where-Object {\$_.type -eq \"product\"}).Title | Select-Object -Unique
517517
if (\$null -eq \$currentEnabledProducts) { \$currentEnabledProducts = @('') }
518518
# compare product families
519519
\$compareProductFamiliesResult = Compare-Object -ReferenceObject \$currentEnabledProductFamilies -DifferenceObject \$desired_productfamilies

0 commit comments

Comments
 (0)