Skip to content

Commit 353b76d

Browse files
committed
Added wrong adapter
1 parent bb4f6c2 commit 353b76d

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

powershell-adapter/psDscAdapter/psDscAdapter.psm1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,19 @@ function Invoke-DscOperation {
464464
$addToActualState.properties = [psobject]@{'InDesiredState' = $Result }
465465
}
466466
'Export' {
467-
$method = ValidateMethod -operation $Operation -class $dscResourceInstance
467+
$t = $dscResourceInstance.GetType()
468+
$methods = $t.GetMethods() | Where-Object { $_.Name -eq 'Export' }
469+
$method = foreach ($mt in $methods) {
470+
if ($mt.GetParameters().Count -eq 0) {
471+
$mt
472+
break
473+
}
474+
}
475+
476+
if ($null -eq $method) {
477+
"Export method not implemented by resource '$($DesiredState.Type)'" | Write-DscTrace -Operation Error
478+
exit 1
479+
}
468480
$resultArray = @()
469481
$raw_obj_array = $method.Invoke($null, $null)
470482
foreach ($raw_obj in $raw_obj_array) {

powershell-adapter/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,21 @@ function Invoke-DscOperation {
438438
$addToActualState.properties = [psobject]@{'InDesiredState' = $Result }
439439
}
440440
'Export' {
441-
$t = $dscResourceInstance.GetType()
442-
$method = $t.GetMethod('Export')
443-
$resultArray = $method.Invoke($null, $null)
441+
$method = ValidateMethod -operation $Operation -class $dscResourceInstance
442+
$resultArray = @()
443+
$raw_obj_array = $method.Invoke($null, $null)
444+
foreach ($raw_obj in $raw_obj_array) {
445+
$Result_obj = @{}
446+
$ValidProperties | ForEach-Object {
447+
if ($raw_obj.$_ -is [System.Enum]) {
448+
$Result_obj[$_] = $raw_obj.$_.ToString()
449+
}
450+
else {
451+
$Result_obj[$_] = $raw_obj.$_
452+
}
453+
}
454+
$resultArray += $Result_obj
455+
}
444456
$addToActualState = $resultArray
445457
}
446458
}

0 commit comments

Comments
 (0)