Skip to content

Commit 9758b1f

Browse files
committed
remove cim properties from script output
1 parent 2a096a5 commit 9758b1f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

powershell-adapter/psDscAdapter/psDscAdapter.psm1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,11 @@ function Get-ActualState {
242242
try {
243243
$getResult = Invoke-DscResource -Method Get -ModuleName $cachedDscResourceInfo.ModuleName -Name $cachedDscResourceInfo.Name -Property $property
244244

245+
# only return DSC properties
246+
$getResult.psobject.Properties.name | Where-Object { 'CimClass','CimInstanceProperties','CimSystemProperties' -notcontains $_ } | ForEach-Object -Begin { $getDscResult = @{} } -Process { $getDscResult[$_] = $getResult.$_ }
247+
245248
# set the properties of the OUTPUT object from the result of Get-TargetResource
246-
$addToActualState.properties = $getResult
249+
$addToActualState.properties = $getDscResult
247250
}
248251
catch {
249252
$trace = @{'Debug' = 'ERROR: ' + $_.Exception.Message } | ConvertTo-Json -Compress
@@ -293,11 +296,8 @@ function Get-ActualState {
293296
try {
294297
$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 )
295298

296-
$trace = @{'Debug' = 'TEMP output: ' + $($getResult | ConvertTo-Json -Depth 10 -Compress) } | ConvertTo-Json -Compress
297-
$host.ui.WriteErrorLine($trace)
298-
299-
# only return DSC properties from the Cim instance
300-
$getresult.psobject.Properties.name | Where-Object { 'CimClass','CimInstanceProperties','CimSystemProperties' -notcontains $_ } | ForEach-Object -Begin { $getDscResult = @{} } -Process { $getDscResult[$_] = $getResult.$_ }
299+
# only return DSC properties
300+
$getResult.psobject.Properties.name | Where-Object { 'CimClass','CimInstanceProperties','CimSystemProperties' -notcontains $_ } | ForEach-Object -Begin { $getDscResult = @{} } -Process { $getDscResult[$_] = $getResult.$_ }
301301

302302
# set the properties of the OUTPUT object from the result of Get-TargetResource
303303
$addToActualState.properties = $getDscResult

0 commit comments

Comments
 (0)