diff --git a/CHANGELOG.md b/CHANGELOG.md index bc3d3d39..12a38055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Proposed fix for WindowsOptionalFeature DSC Resource GET method when the OptionalFeature has no Custom Properties. + [Issue #191](https://github.com/PowerShell/PSDscResources/issues/191) + ## 2.12.0.0 * Ports style fixes that were recently made in xPSDesiredStateConfiguration diff --git a/DscResources/MSFT_WindowsOptionalFeature/MSFT_WindowsOptionalFeature.psm1 b/DscResources/MSFT_WindowsOptionalFeature/MSFT_WindowsOptionalFeature.psm1 index d9d7d705..8c44ba6b 100644 --- a/DscResources/MSFT_WindowsOptionalFeature/MSFT_WindowsOptionalFeature.psm1 +++ b/DscResources/MSFT_WindowsOptionalFeature/MSFT_WindowsOptionalFeature.psm1 @@ -330,7 +330,7 @@ function Convert-CustomPropertyArrayToStringArray } } - return $propertiesAsStrings + Write-Output $propertiesAsStrings -NoEnumerate } <# diff --git a/Tests/Unit/MSFT_WindowsOptionalFeature.Tests.ps1 b/Tests/Unit/MSFT_WindowsOptionalFeature.Tests.ps1 index 27775394..d5e844e6 100644 --- a/Tests/Unit/MSFT_WindowsOptionalFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_WindowsOptionalFeature.Tests.ps1 @@ -317,6 +317,10 @@ try $propertiesAsStrings.Contains("Name = Object $objectNumber, Value = Value $objectNumber, Path = Path $objectNumber") | Should -BeTrue } } + + It 'Should return an empty array and not a null object when input is an empty array' { + (Convert-CustomPropertyArrayToStringArray -CustomProperties @()) -is [String[]] | Should -BeTrue + } } } }