@@ -36,7 +36,6 @@ function Get-DscResourceObject {
36
36
}
37
37
38
38
function GetValidCimProperties {
39
- [OutputType ()]
40
39
[CmdletBinding ()]
41
40
param
42
41
(
@@ -113,38 +112,7 @@ function GetValidCimProperties {
113
112
}
114
113
115
114
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
+ }
148
116
149
117
return $validatedProperties
150
118
}
@@ -247,10 +215,12 @@ function GetCimSpace {
247
215
}
248
216
249
217
$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
251
222
$result += $addToActualState
252
223
}
253
-
254
224
}
255
225
' Set' {
256
226
$wmi_instance = ValidateCimMethodAndArguments - DesiredState $r
@@ -352,11 +322,11 @@ class dscResourceObject {
352
322
}
353
323
354
324
$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"
357
327
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
361
331
}
362
332
}
0 commit comments