@@ -355,15 +355,15 @@ function Invoke-DscOperation {
355355 $invokeResult = Invoke-DscResource - Method $Operation - ModuleName $cachedDscResourceInfo.ModuleName - Name $cachedDscResourceInfo.Name - Property $property
356356
357357 if ($invokeResult.GetType ().Name -eq ' Hashtable' ) {
358- $invokeResult.keys | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $invokeResult .$_ }
358+ $invokeResult.keys | ForEach-Object - Begin { $ResultProperties = @ {} } - Process { $ResultProperties [$_ ] = $invokeResult .$_ }
359359 }
360360 else {
361361 # the object returned by WMI is a CIM instance with a lot of additional data. only return DSC properties
362- $invokeResult.psobject.Properties.name | Where-Object { ' CimClass' , ' CimInstanceProperties' , ' CimSystemProperties' -notcontains $_ } | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $invokeResult .$_ }
362+ $invokeResult.psobject.Properties.name | Where-Object { ' CimClass' , ' CimInstanceProperties' , ' CimSystemProperties' -notcontains $_ } | ForEach-Object - Begin { $ResultProperties = @ {} } - Process { $ResultProperties [$_ ] = $invokeResult .$_ }
363363 }
364364
365365 # set the properties of the OUTPUT object from the result of Get-TargetResource
366- $addToActualState.properties = $getDscResult
366+ $addToActualState.properties = $ResultProperties
367367 }
368368 catch {
369369 ' ERROR: ' + $_.Exception.Message | Write-DscTrace
@@ -422,21 +422,19 @@ function Invoke-DscOperation {
422422
423423 # morph the INPUT object into a hashtable named "property" for the cmdlet Invoke-DscResource
424424 $DesiredState.properties.psobject.properties | ForEach-Object - Begin { $property = @ {} } - Process { $property [$_.Name ] = $_.Value }
425-
426425 # using the cmdlet from PSDesiredStateConfiguration module in Windows
427426 try {
428- $getResult = $PSDesiredStateConfiguration.invoke ({ param ($Name , $Property ) Invoke-DscResource - Name $Name - Method Get - ModuleName @ {ModuleName = ' PSDesiredStateConfiguration' ; ModuleVersion = ' 1.1' } - Property $Property - ErrorAction Stop }, $cachedDscResourceInfo.Name , $property )
429-
430- if ($getResult.GetType ().Name -eq ' Hashtable' ) {
431- $getResult.keys | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
427+ $invokeResult = Invoke-DscResource - Method $Operation - ModuleName $cachedDscResourceInfo.ModuleName - Name $cachedDscResourceInfo.Name - Property $property
428+ if ($invokeResult.GetType ().Name -eq ' Hashtable' ) {
429+ $invokeResult.keys | ForEach-Object - Begin { $ResultProperties = @ {} } - Process { $ResultProperties [$_ ] = $invokeResult .$_ }
432430 }
433431 else {
434432 # the object returned by WMI is a CIM instance with a lot of additional data. only return DSC properties
435- $getResult .psobject.Properties.name | Where-Object { ' CimClass' , ' CimInstanceProperties' , ' CimSystemProperties' -notcontains $_ } | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
433+ $invokeResult .psobject.Properties.name | Where-Object { ' CimClass' , ' CimInstanceProperties' , ' CimSystemProperties' -notcontains $_ } | ForEach-Object - Begin { $ResultProperties = @ {} } - Process { $ResultProperties [$_ ] = $invokeResult .$_ }
436434 }
437435
438436 # set the properties of the OUTPUT object from the result of Get-TargetResource
439- $addToActualState.properties = $getDscResult
437+ $addToActualState.properties = $ResultProperties
440438 }
441439 catch {
442440 ' ERROR: ' + $_.Exception.Message | Write-DscTrace
0 commit comments