File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
powershell-adapter/psDscAdapter Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments