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 {
464
464
$addToActualState.properties = [psobject ]@ {' InDesiredState' = $Result }
465
465
}
466
466
' 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
+ }
468
480
$resultArray = @ ()
469
481
$raw_obj_array = $method.Invoke ($null , $null )
470
482
foreach ($raw_obj in $raw_obj_array ) {
Original file line number Diff line number Diff line change @@ -438,9 +438,21 @@ function Invoke-DscOperation {
438
438
$addToActualState.properties = [psobject ]@ {' InDesiredState' = $Result }
439
439
}
440
440
' 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
+ }
444
456
$addToActualState = $resultArray
445
457
}
446
458
}
You can’t perform that action at this time.
0 commit comments