File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -108,4 +108,16 @@ Describe 'WMI adapter resource tests' {
108108 $res.afterState.VariableValue | Should - Be ' update'
109109 $res.afterState.UserName | Should - Be (" {0}\{1}" -f $env: USERDOMAIN , $env: USERNAME )
110110 }
111+
112+ It ' Get works with read-only properties on Win32_ComputerSystem' - Skip:(! $IsWindows ) {
113+ $manufacturer = (Get-CimInstance - ClassName Win32_ComputerSystem).Manufacturer
114+ $i = @ {
115+ Manufacturer = $manufacturer
116+ } | ConvertTo-Json
117+
118+ $r = dsc resource get - r root.cimv2/ Win32_ComputerSystem - i $i
119+ $LASTEXITCODE | Should - Be 0
120+ $res = $r | ConvertFrom-Json
121+ $res.actualState.Manufacturer | Should - Be $manufacturer
122+ }
111123}
Original file line number Diff line number Diff line change @@ -122,11 +122,12 @@ function BuildWmiQuery {
122122 [Parameter (Mandatory = $true )]
123123 [string ]$ClassName ,
124124
125- [Parameter (Mandatory = $true )]
126- [array ]$Properties ,
127-
128125 [Parameter (Mandatory = $true )]
129126 [psobject ]$DesiredStateProperties ,
127+
128+ [Parameter ()]
129+ [AllowNull ()]
130+ [array ]$Properties ,
130131
131132 [Parameter ()]
132133 [switch ]$KeyPropertiesOnly
@@ -205,6 +206,8 @@ function GetWmiInstance {
205206 }
206207 }
207208 }
209+ } else {
210+ $wmi_instances = Get-CimInstance - Namespace $wmi_namespace - ClassName $wmi_classname - ErrorAction Ignore - ErrorVariable Err
208211 }
209212 } else {
210213 $wmi_instances = Get-CimInstance - Namespace $wmi_namespace - ClassName $wmi_classname - ErrorAction Ignore - ErrorVariable Err
@@ -365,4 +368,4 @@ class dscResourceObject {
365368 [string ] $name
366369 [string ] $type
367370 [PSCustomObject ] $properties
368- }
371+ }
You can’t perform that action at this time.
0 commit comments