Skip to content

Commit a057a31

Browse files
author
Andrew
committed
updated psDscAdapter.psm1
1 parent 097350b commit a057a31

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

powershell-adapter/psDscAdapter/psDscAdapter.psm1

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ function Invoke-DscOperation {
460460
$resource = GetTypeInstanceFromModule -modulename $cachedDscResourceInfo.ModuleName -classname $cachedDscResourceInfo.Name
461461
$dscResourceInstance = $resource::New()
462462

463+
$ValidProperties = $cachedDscResourceInfo.Properties.Name
464+
463465
if ($DesiredState.properties) {
464466
# set each property of $dscResourceInstance to the value of the property in the $desiredState INPUT object
465467
$DesiredState.properties.psobject.properties | ForEach-Object -Process {
@@ -469,14 +471,18 @@ function Invoke-DscOperation {
469471

470472
switch ($Operation) {
471473
'Get' {
472-
$Result = $dscResourceInstance.Get()
474+
$Result = @{}
475+
$raw_obj = $dscResourceInstance.Get()
476+
$ValidProperties | %{ $Result[$_] = $raw_obj[$_] }
473477
$addToActualState.properties = $Result
474478
}
475479
'Set' {
476480
$dscResourceInstance.Set()
477481
}
478482
'Test' {
479-
$Result = $dscResourceInstance.Test()
483+
$Result = @{}
484+
$raw_obj = $dscResourceInstance.Test()
485+
$ValidProperties | %{ $Result[$_] = $raw_obj[$_] }
480486
$addToActualState.properties = [psobject]@{'InDesiredState'=$Result}
481487
}
482488
'Export' {
@@ -486,7 +492,13 @@ function Invoke-DscOperation {
486492
"Export method not implemented by resource '$($DesiredState.Type)'" | Write-DscTrace -Operation Error
487493
exit 1
488494
}
489-
$resultArray = $method.Invoke($null,$null)
495+
$resultArray = @()
496+
$raw_obj_array = $method.Invoke($null,$null)
497+
foreach ($raw_obj in $raw_obj_array) {
498+
$Result_obj = @{}
499+
$ValidProperties | %{ $Result_obj[$_] = $raw_obj[$_] }
500+
$resultArray += $Result_obj
501+
}
490502
$addToActualState = $resultArray
491503
}
492504
}

0 commit comments

Comments
 (0)