@@ -36,7 +36,6 @@ function Get-DscResourceObject {
3636}
3737
3838function GetValidCimProperties {
39- [OutputType ()]
4039 [CmdletBinding ()]
4140 param
4241 (
@@ -113,38 +112,7 @@ function GetValidCimProperties {
113112 }
114113
115114 return $availableProperties
116- }
117-
118- # if ($SkipReadOnly.IsPresent) {
119- # # For 'Set', we need to validate that the provided properties match the CIM class
120- # $availableProperties = $cimClass.CimClassProperties | ForEach-Object {
121- # [string[]]$flags = $_.Flags.ToString().Split(",").Trim()
122- # if ($flags -notcontains 'ReadOnly' -or $flags -contains 'Key') {
123- # $_
124- # }
125- # }
126-
127- # # Reset the validated properties list as we only want to capture non-readonly properties for 'Set'
128- # $validatedProperties = [System.Collections.Generic.List[Array]]::new()
129- # foreach ($property in $availableProperties) {
130- # $propName = $property.Name
131- # $isKey = $property.IsKey
132-
133- # if ($isKey) {
134- # # Still check here if the key property is passed as we continue
135- # if ($Properties.psobject.properties.name -notcontains $propName -or $null -eq $properties.$propName -or $Properties.$propName -eq '') {
136- # "Key property '$propName' is required but not provided or is empty." | Write-DscTrace -Operation Error
137- # exit 1
138- # } else {
139- # $validatedProperties.Add($property)
140- # }
141- # } elseif ($Properties.psobject.Properties.name -contains $propName) {
142- # $validatedProperties.Add($property)
143- # } else {
144- # "Property '$propName' is not provided in the resource object." | Write-DscTrace -Operation Trace
145- # }
146- # }
147- # }
115+ }
148116
149117 return $validatedProperties
150118}
@@ -247,10 +215,12 @@ function GetCimSpace {
247215 }
248216
249217 $addToActualState.properties = $instance_result
250-
218+ $result += $addToActualState
219+ } else {
220+ " No WMI instances found for type '$ ( $r.type ) '." | Write-DscTrace - Operation Warn
221+ $addToActualState.properties = $null
251222 $result += $addToActualState
252223 }
253-
254224 }
255225 ' Set' {
256226 $wmi_instance = ValidateCimMethodAndArguments - DesiredState $r
@@ -352,11 +322,11 @@ class dscResourceObject {
352322}
353323
354324$out = [dscResourceObject ]@ {
355- name = ' root.cimv2/Win32_Environment'
356- type = ' root.cimv2/Win32_Environment'
325+ name = " root.cimv2/Win32_Environment"
326+ type = " root.cimv2/Win32_Environment"
357327 properties = [PSCustomObject ]@ {
358- UserName = " {0}\{1} " -f $ env: USERDOMAIN , $ env: USERNAME
359- VariableValue = ' update '
360- Name = ' test '
328+ Name = " test "
329+ Value = " test "
330+ UserName = ( " {0}\{1} " -f $ env: USERDOMAIN , $ env: USERNAME ) # Read-only key property required
361331 }
362332}
0 commit comments