@@ -55,7 +55,7 @@ function Invoke-DscCacheRefresh {
55
55
}
56
56
elseif (' PSDesiredStateConfiguration' -eq $module ) {
57
57
# workaround: the binary modules don't have a module name, so we have to special case File and SignatureValidation resources that ship in Windows
58
- $DscResources = Get-DscResource | Where-Object { $_.modulename -eq ' PSDesiredStateConfiguration' -or ( $_.modulename -eq $null -and $_.parentpath -like " $env: windir \System32\Configuration\*" )}
58
+ $DscResources = Get-DscResource | Where-Object { $_.modulename -eq ' PSDesiredStateConfiguration' -or ( $_.modulename -eq $null -and $_.parentpath -like " $env: windir \System32\Configuration\*" ) }
59
59
}
60
60
else {
61
61
# if no module is specified, get all resources
@@ -242,9 +242,14 @@ function Get-ActualState {
242
242
try {
243
243
$getResult = Invoke-DscResource - Method Get - ModuleName $cachedDscResourceInfo.ModuleName - Name $cachedDscResourceInfo.Name - Property $property
244
244
245
- # only return DSC properties
246
- $getResult.psobject.Properties.name | Where-Object { ' CimClass' , ' CimInstanceProperties' , ' CimSystemProperties' -notcontains $_ } | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
247
-
245
+ if ($getResult.GetType ().Name -eq ' Hashtable' ) {
246
+ $getResult.keys | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
247
+ }
248
+ else {
249
+ # the object returned by WMI is a CIM instance with a lot of additional data. only return DSC properties
250
+ $getResult.psobject.Properties.name | Where-Object { ' CimClass' , ' CimInstanceProperties' , ' CimSystemProperties' -notcontains $_ } | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
251
+ }
252
+
248
253
# set the properties of the OUTPUT object from the result of Get-TargetResource
249
254
$addToActualState.properties = $getDscResult
250
255
}
@@ -296,9 +301,14 @@ function Get-ActualState {
296
301
try {
297
302
$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 )
298
303
299
- # only return DSC properties
300
- $getResult.psobject.Properties.name | Where-Object { ' CimClass' , ' CimInstanceProperties' , ' CimSystemProperties' -notcontains $_ } | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
301
-
304
+ if ($getResult.GetType ().Name -eq ' Hashtable' ) {
305
+ $getResult.keys | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
306
+ }
307
+ else {
308
+ # the object returned by WMI is a CIM instance with a lot of additional data. only return DSC properties
309
+ $getResult.psobject.Properties.name | Where-Object { ' CimClass' , ' CimInstanceProperties' , ' CimSystemProperties' -notcontains $_ } | ForEach-Object - Begin { $getDscResult = @ {} } - Process { $getDscResult [$_ ] = $getResult .$_ }
310
+ }
311
+
302
312
# set the properties of the OUTPUT object from the result of Get-TargetResource
303
313
$addToActualState.properties = $getDscResult
304
314
}
0 commit comments