diff --git a/powershell-adapter/Tests/TestClassResource/0.0.1/TestClassResource.psm1 b/powershell-adapter/Tests/TestClassResource/0.0.1/TestClassResource.psm1 index 641cee6b..486e25a7 100644 --- a/powershell-adapter/Tests/TestClassResource/0.0.1/TestClassResource.psm1 +++ b/powershell-adapter/Tests/TestClassResource/0.0.1/TestClassResource.psm1 @@ -81,6 +81,30 @@ class TestClassResource : BaseTestClass return $resultList.ToArray() } + + static [TestClassResource[]] Export([bool]$UseExport) + { + if ($UseExport) + { + return [TestClassResource]::Export() + } + else + { + $resultList = [List[TestClassResource]]::new() + $resultCount = 5 + if ($env:TestClassResourceResultCount) { + $resultCount = $env:TestClassResourceResultCount + } + 1..$resultCount | %{ + $obj = New-Object TestClassResource + $obj.Name = "Object$_" + $obj.Prop1 = "Property of object$_" + $resultList.Add($obj) + } + } + + return $resultList.ToArray() + } } [DscResource()] diff --git a/powershell-adapter/psDscAdapter/psDscAdapter.psm1 b/powershell-adapter/psDscAdapter/psDscAdapter.psm1 index 5c470535..2aad54cc 100644 --- a/powershell-adapter/psDscAdapter/psDscAdapter.psm1 +++ b/powershell-adapter/psDscAdapter/psDscAdapter.psm1 @@ -485,7 +485,14 @@ function Invoke-DscOperation { } 'Export' { $t = $dscResourceInstance.GetType() - $method = $t.GetMethod('Export') + $methods = $t.GetMethods() | Where-Object { $_.Name -eq 'Export' } + $method = foreach ($mt in $methods) { + if ($mt.GetParameters().Count -eq 0) { + $mt + break + } + } + if ($null -eq $method) { "Export method not implemented by resource '$($DesiredState.Type)'" | Write-DscTrace -Operation Error exit 1