@@ -88,8 +88,12 @@ function Invoke-DscCacheRefresh {
88
88
)
89
89
$DscResourceInfo = [DscResourceInfo ]::new()
90
90
$dscResource.PSObject.Properties | ForEach-Object - Process {
91
- if ($null -eq $_.Value ) { $_.Value = ' ' }
92
- $DscResourceInfo .$ ($_.Name ) = $_.Value
91
+ if ($null -ne $_.Value ) {
92
+ $DscResourceInfo .$ ($_.Name ) = $_.Value
93
+ }
94
+ else {
95
+ $DscResourceInfo .$ ($_.Name ) = ' '
96
+ }
93
97
}
94
98
if ($dscResource.ModuleName ) {
95
99
$moduleName = $dscResource.ModuleName
@@ -286,13 +290,13 @@ function Get-ActualState {
286
290
287
291
# using the cmdlet from PSDesiredStateConfiguration module in Windows
288
292
try {
289
- $getResult = $PSDesiredStateConfiguration.invoke ({ param ($Name , $Property ) Invoke-DscResource - Name $Name - Method Get - ModuleName @ {ModuleName = ' PSDesiredStateConfiguration' ; ModuleVersion = ' 1.1' } - Property $Property }, $cachedDscResourceInfo.Name , $property )
293
+ $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 )
290
294
291
295
$trace = @ {' Debug' = ' TEMP output: ' + $ ($getResult | ConvertTo-Json - Depth 10 - Compress) } | ConvertTo-Json - Compress
292
296
$host.ui.WriteErrorLine ($trace )
293
297
294
298
# only return DSC properties from the Cim instance
295
- $cachedDscResourceInfo . Properties.Name | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
299
+ $getresult .psobject. Properties.name | Where-Object { ' CimClass ' , ' CimInstanceProperties ' , ' CimSystemProperties ' -notcontains $_ } | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
296
300
297
301
# set the properties of the OUTPUT object from the result of Get-TargetResource
298
302
$addToActualState.properties = $getDscResult
0 commit comments