Skip to content

Commit

Permalink
Fixing processing of multiple Product categories
Browse files Browse the repository at this point in the history
with the same name
Fix dsccommunity#61
  • Loading branch information
Martin Vokurek committed Feb 12, 2021
1 parent dd6be4e commit 79c0f70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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($_)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @('*')
Expand All @@ -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)
Expand Down Expand Up @@ -579,7 +579,7 @@ if ($WsusConfiguration.OobeInitialized)
{
foreach ($Product in $AllWsusProducts)
{
$null = $ProductCollection.Add($WsusServer.GetUpdateCategory($Product.Id))
$null = $ProductCollection.Add($Product)
}
}
else
Expand All @@ -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($_)
}
}
}
}
Expand Down

0 comments on commit 79c0f70

Please sign in to comment.