@@ -108,172 +108,3 @@ class resourceOutput {
108
108
[string ] $requireAdapter
109
109
[string ] $description
110
110
}
111
-
112
- # [CmdletBinding()]
113
- # param(
114
- # [ValidateSet('List','Get','Set','Test','Validate')]
115
- # $Operation = 'List',
116
- # [Parameter(ValueFromPipeline)]
117
- # $stdinput
118
- # )
119
-
120
- # # catch any un-caught exception and write it to the error stream
121
- # trap {
122
- # Write-Trace -Level Error -message $_.Exception.Message
123
- # exit 1
124
- # }
125
-
126
- # $ProgressPreference = 'Ignore'
127
- # $WarningPreference = 'Ignore'
128
- # $VerbosePreference = 'Ignore'
129
-
130
- # function Write-Trace {
131
- # param(
132
- # [string]$message,
133
- # [string]$level = 'Error'
134
- # )
135
-
136
- # $trace = [pscustomobject]@{
137
- # $level.ToLower() = $message
138
- # } | ConvertTo-Json -Compress
139
-
140
- # $host.ui.WriteErrorLine($trace)
141
- # }
142
-
143
- # if ($Operation -eq 'List')
144
- # {
145
- # $clases = Get-CimClass
146
-
147
-
148
- # foreach ($r in $clases)
149
- # {
150
- # $version_string = "";
151
- # $author_string = "";
152
-
153
- # $propertyList = @()
154
- # foreach ($p in $r.CimClassProperties)
155
- # {
156
- # if ($p.Name)
157
- # {
158
- # $propertyList += $p.Name
159
- # }
160
- # }
161
-
162
- # $namespace = $r.CimSystemProperties.Namespace.ToLower().Replace('/','.')
163
- # $classname = $r.CimSystemProperties.ClassName
164
- # $fullResourceTypeName = "$namespace/$classname"
165
- # $requiresString = "Microsoft.Windows/WMI"
166
-
167
- # $z = [pscustomobject]@{
168
- # type = $fullResourceTypeName;
169
- # kind = 'resource';
170
- # version = $version_string;
171
- # capabilities = @('get');
172
- # path = "";
173
- # directory = "";
174
- # implementedAs = "";
175
- # author = $author_string;
176
- # properties = $propertyList;
177
- # requireAdapter = $requiresString
178
- # }
179
-
180
- # $z | ConvertTo-Json -Compress
181
- # }
182
- # }
183
- # elseif ($Operation -eq 'Get')
184
- # {
185
- # $inputobj_pscustomobj = $null
186
- # if ($stdinput)
187
- # {
188
- # $inputobj_pscustomobj = $stdinput | ConvertFrom-Json
189
- # }
190
-
191
- # $result = @()
192
-
193
- # foreach ($r in $inputobj_pscustomobj.resources)
194
- # {
195
- # $type_fields = $r.type -split "/"
196
- # $wmi_namespace = $type_fields[0].Replace('.','\')
197
- # $wmi_classname = $type_fields[1]
198
-
199
- # # TODO: identify key properties and add WHERE clause to the query
200
- # if ($r.properties)
201
- # {
202
- # $query = "SELECT $($r.properties.psobject.properties.name -join ',') FROM $wmi_classname"
203
- # $where = " WHERE "
204
- # $useWhere = $false
205
- # $first = $true
206
- # foreach ($property in $r.properties.psobject.properties)
207
- # {
208
- # # TODO: validate property against the CIM class to give better error message
209
- # if ($null -ne $property.value)
210
- # {
211
- # $useWhere = $true
212
- # if ($first)
213
- # {
214
- # $first = $false
215
- # }
216
- # else
217
- # {
218
- # $where += " AND "
219
- # }
220
-
221
- # if ($property.TypeNameOfValue -eq "System.String")
222
- # {
223
- # $where += "$($property.Name) = '$($property.Value)'"
224
- # }
225
- # else
226
- # {
227
- # $where += "$($property.Name) = $($property.Value)"
228
- # }
229
- # }
230
- # }
231
- # if ($useWhere)
232
- # {
233
- # $query += $where
234
- # }
235
- # Write-Trace -Level Trace -message "Query: $query"
236
- # $wmi_instances = Get-CimInstance -Namespace $wmi_namespace -Query $query -ErrorAction Stop
237
- # }
238
- # else
239
- # {
240
- # $wmi_instances = Get-CimInstance -Namespace $wmi_namespace -ClassName $wmi_classname -ErrorAction Stop
241
- # }
242
-
243
- # if ($wmi_instances)
244
- # {
245
- # $instance_result = [ordered]@{}
246
- # # TODO: for a `Get`, they key property must be provided so a specific instance is returned rather than just the first
247
- # $wmi_instance = $wmi_instances[0] # for 'Get' we return just first matching instance; for 'export' we return all instances
248
- # $wmi_instance.psobject.properties | %{
249
- # if (($_.Name -ne "type") -and (-not $_.Name.StartsWith("Cim")))
250
- # {
251
- # if ($r.properties)
252
- # {
253
- # if ($r.properties.psobject.properties.name -contains $_.Name)
254
- # {
255
- # $instance_result[$_.Name] = $_.Value
256
- # }
257
- # }
258
- # else
259
- # {
260
- # $instance_result[$_.Name] = $_.Value
261
- # }
262
- # }
263
- # }
264
-
265
- # $result += [pscustomobject]@{ name = $r.name; type = $r.type; properties = $instance_result }
266
- # }
267
- # }
268
-
269
- # @{result = $result } | ConvertTo-Json -Depth 10 -Compress
270
- # }
271
- # elseif ($Operation -eq 'Validate')
272
- # {
273
- # # TODO: this is placeholder
274
- # @{ valid = $true } | ConvertTo-Json
275
- # }
276
- # else
277
- # {
278
- # Write-Trace "ERROR: Unsupported operation requested from wmigroup.resource.ps1"
279
- # }
0 commit comments