From 79c0f70357328356a54bc9832a00b5ae87460e8e Mon Sep 17 00:00:00 2001 From: Martin Vokurek Date: Fri, 12 Feb 2021 21:43:56 +0100 Subject: [PATCH 1/3] Fixing processing of multiple Product categories with the same name Fix #61 --- CHANGELOG.md | 6 ++++++ .../MSFT_UpdateServicesApprovalRule.psm1 | 7 +++++-- .../MSFT_UpdateServicesServer.psm1 | 12 +++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42319b9..024f173 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fixed `UpdateServicesServer` and `UpdateServicesApprovalRule` + - Process multiple product categories with the same name correctly (e.g. "Windows Admin Center") + - Verbose output of Products only displayed one product + ### Changed - Updated inital offline package sync WSUS.cab. diff --git a/source/DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 b/source/DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 index 361d00e..87f4c11 100644 --- a/source/DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 +++ b/source/DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 @@ -215,11 +215,14 @@ function Set-TargetResource $ApprovalRule.Save() $ProductCollection = New-Object -TypeName Microsoft.UpdateServices.Administration.UpdateCategoryCollection + $AllWsusProducts = $WsusServer.GetUpdateCategories() foreach ($Product in $Products) { - if ($WsusProduct = Get-WsusProduct | Where-Object -FilterScript { $_.Product.Title -eq $Product }) + if ($WsusProduct = $AllWsusProducts | Where-Object -FilterScript { $_.Title -eq $Product }) { - $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusProduct.Product.Id)) + $WsusProduct | Foreach-Object { + $ProductCollection.Add($_) + } } } diff --git a/source/DSCResources/MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 b/source/DSCResources/MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 index 8759fa5..a034b19 100644 --- a/source/DSCResources/MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 +++ b/source/DSCResources/MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 @@ -141,9 +141,9 @@ function Get-TargetResource Write-Verbose -Message ($script:localizedData.WsusClassifications -f $Classifications) Write-Verbose -Message $script:localizedData.GettingWsusProducts - if ($Products = @($WsusSubscription.GetUpdateCategories().Title)) + if ($Products = (@($WsusSubscription.GetUpdateCategories().Title) | Sort-Object -Unique)) { - if ($null -eq (Compare-Object -ReferenceObject ($Products | Sort-Object -Unique) -DifferenceObject ` + if ($null -eq (Compare-Object -ReferenceObject $Products -DifferenceObject ` (($WsusServer.GetUpdateCategories().Title) | Sort-Object -Unique) -SyncWindow 0)) { $Products = @('*') @@ -154,7 +154,7 @@ function Get-TargetResource $Products = @('*') } - Write-Verbose -Message ($script:localizedData.WsusProducts -f $Products) + Write-Verbose -Message ($script:localizedData.WsusProducts -f ($Products -join ', ')) Write-Verbose -Message $script:localizedData.GettingWsusSyncConfig $SynchronizeAutomatically = $WsusSubscription.SynchronizeAutomatically Write-Verbose -Message ($script:localizedData.WsusSyncAuto -f $SynchronizeAutomatically) @@ -579,7 +579,7 @@ if ($WsusConfiguration.OobeInitialized) { foreach ($Product in $AllWsusProducts) { - $null = $ProductCollection.Add($WsusServer.GetUpdateCategory($Product.Id)) + $null = $ProductCollection.Add($Product) } } else @@ -588,7 +588,9 @@ if ($WsusConfiguration.OobeInitialized) { if ($WsusProduct = $AllWsusProducts | Where-Object -FilterScript { $_.Title -eq $Product }) { - $null = $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusProduct.Id)) + $WsusProduct | Foreach-Object -Process { + $null = $ProductCollection.Add($_) + } } } } From 79dddce607a0867db5ef5daad401de9f9fd7b333 Mon Sep 17 00:00:00 2001 From: Martin Vokurek Date: Fri, 12 Feb 2021 21:57:48 +0100 Subject: [PATCH 2/3] Fixing verbose output of Languages Fix #62 --- CHANGELOG.md | 1 + .../MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 024f173..9b0fbf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed `UpdateServicesServer` and `UpdateServicesApprovalRule` - Process multiple product categories with the same name correctly (e.g. "Windows Admin Center") - Verbose output of Products only displayed one product +- Fixed verbose output of Languages in `UpdateServiceServer` ### Changed diff --git a/source/DSCResources/MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 b/source/DSCResources/MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 index a034b19..d8529b5 100644 --- a/source/DSCResources/MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 +++ b/source/DSCResources/MSFT_UpdateServicesServer/MSFT_UpdateServicesServer.psm1 @@ -121,7 +121,7 @@ function Get-TargetResource } else { - $Languages = $WsusConfiguration.GetEnabledUpdateLanguages() + $Languages = ($WsusConfiguration.GetEnabledUpdateLanguages()) -join ',' } Write-Verbose -Message ($script:localizedData.WsusLanguages -f $Languages) From d48f934819632d8df71a672706cce55e902f2f9e Mon Sep 17 00:00:00 2001 From: Martin Vokurek Date: Fri, 12 Feb 2021 22:01:38 +0100 Subject: [PATCH 3/3] Fixing verbose output of WSUS server name Fix #63 --- CHANGELOG.md | 1 + .../MSFT_UpdateServicesApprovalRule.psm1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b0fbf6..9d7c8dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Process multiple product categories with the same name correctly (e.g. "Windows Admin Center") - Verbose output of Products only displayed one product - Fixed verbose output of Languages in `UpdateServiceServer` +- Fixed verbose output of WSUS server in `UpdateServicesApprovalRule` ### Changed diff --git a/source/DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 b/source/DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 index 87f4c11..39376b8 100644 --- a/source/DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 +++ b/source/DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 @@ -52,7 +52,7 @@ function Get-TargetResource if ($null -ne $WsusServer) { - Write-Verbose -Message ('Identified WSUS server information: {0}' -f $WsusServer) + Write-Verbose -Message ('Identified WSUS server information: {0}' -f $WsusServer.Name) $ApprovalRule = $WsusServer.GetInstallApprovalRules() | Where-Object -FilterScript { $_.Name -eq $Name }