Skip to content

Commit 55eb4ba

Browse files
committed
Update test
1 parent 3f5ed2e commit 55eb4ba

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

powershell-adapter/Tests/win_powershellgroup.tests.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ class PSClassResource {
347347
$out = dsc resource get -r PSClassResource/PSClassResource --input (@{Name = 'TestName' } | ConvertTo-Json) | ConvertFrom-Json
348348
$LASTEXITCODE | Should -Be 0
349349
$out.actualState.Name | Should -Be 'TestName'
350+
$propCount = $out.actualState | Get-Member -MemberType NoteProperty
351+
$propCount.Count | Should -Be 1 # Only the DscProperty should be returned
350352
}
351353

352354
It 'Set works with class-based PS DSC resources' -Skip:(!$IsWindows) {

powershell-adapter/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ function Invoke-DscOperation {
402402
$resource = GetTypeInstanceFromModule -modulename $cachedDscResourceInfo.ModuleName -classname $cachedDscResourceInfo.Name
403403
$dscResourceInstance = $resource::New()
404404

405+
$ValidProperties = $cachedDscResourceInfo.Properties.Name
406+
407+
$ValidProperties | ConvertTo-Json | Write-DscTrace -Operation Trace
408+
405409
if ($DesiredState.properties) {
406410
# set each property of $dscResourceInstance to the value of the property in the $desiredState INPUT object
407411
$DesiredState.properties.psobject.properties | ForEach-Object -Process {
@@ -427,7 +431,17 @@ function Invoke-DscOperation {
427431

428432
switch ($Operation) {
429433
'Get' {
430-
$Result = $dscResourceInstance.Get()
434+
$Result = @{}
435+
$raw_obj = $dscResourceInstance.Get()
436+
$ValidProperties | ForEach-Object {
437+
if ($raw_obj.$_ -is [System.Enum]) {
438+
$Result[$_] = $raw_obj.$_.ToString()
439+
440+
}
441+
else {
442+
$Result[$_] = $raw_obj.$_
443+
}
444+
}
431445
$addToActualState.properties = $Result
432446
}
433447
'Set' {

0 commit comments

Comments
 (0)