@@ -355,15 +355,15 @@ function Invoke-DscOperation {
355
355
$invokeResult = Invoke-DscResource - Method $Operation - ModuleName $cachedDscResourceInfo.ModuleName - Name $cachedDscResourceInfo.Name - Property $property
356
356
357
357
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 .$_ }
359
359
}
360
360
else {
361
361
# 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 .$_ }
363
363
}
364
364
365
365
# set the properties of the OUTPUT object from the result of Get-TargetResource
366
- $addToActualState.properties = $getDscResult
366
+ $addToActualState.properties = $ResultProperties
367
367
}
368
368
catch {
369
369
' ERROR: ' + $_.Exception.Message | Write-DscTrace
@@ -422,21 +422,19 @@ function Invoke-DscOperation {
422
422
423
423
# morph the INPUT object into a hashtable named "property" for the cmdlet Invoke-DscResource
424
424
$DesiredState.properties.psobject.properties | ForEach-Object - Begin { $property = @ {} } - Process { $property [$_.Name ] = $_.Value }
425
-
426
425
# using the cmdlet from PSDesiredStateConfiguration module in Windows
427
426
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 .$_ }
432
430
}
433
431
else {
434
432
# 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 .$_ }
436
434
}
437
435
438
436
# set the properties of the OUTPUT object from the result of Get-TargetResource
439
- $addToActualState.properties = $getDscResult
437
+ $addToActualState.properties = $ResultProperties
440
438
}
441
439
catch {
442
440
' ERROR: ' + $_.Exception.Message | Write-DscTrace
0 commit comments