@@ -158,12 +158,14 @@ function Out-PolicyExemptions {
158
158
}
159
159
# Logic to force the order of the Metadata property (DeployedBy first, then epacMetadata)
160
160
foreach ($array in $jsonArray ) {
161
- $meta = $array.Metadata
162
- $orderedMeta = [ordered ]@ {
163
- deployedBy = $meta [' deployedBy' ]
164
- epacMetadata = $meta [' epacMetadata' ]
161
+ if ($null -ne $array.Metadata ) {
162
+ $meta = $array.Metadata
163
+ $orderedMeta = [ordered ]@ {
164
+ deployedBy = $meta [' deployedBy' ]
165
+ epacMetadata = $meta [' epacMetadata' ]
166
+ }
167
+ $array.Metadata = $orderedMeta
165
168
}
166
- $array.Metadata = $orderedMeta
167
169
}
168
170
$jsonFile = " $stem .$FileExtension "
169
171
if (Test-Path $jsonFile ) {
@@ -193,14 +195,16 @@ function Out-PolicyExemptions {
193
195
}
194
196
# Logic to force the order of the Metadata property (DeployedBy first, then epacMetadata)
195
197
foreach ($array in $excelArray ) {
196
- $metaString = $array.Metadata
197
- $meta = $metaString | ConvertFrom-Json - Depth 100
198
- $orderedMeta = [ordered ]@ {
199
- deployedBy = $meta.deployedBy
200
- epacMetadata = $meta.epacMetadata
198
+ if ($null -ne $array.Metadata ) {
199
+ $metaString = $array.Metadata
200
+ $meta = $metaString | ConvertFrom-Json - Depth 100
201
+ $orderedMeta = [ordered ]@ {
202
+ deployedBy = $meta.deployedBy
203
+ epacMetadata = $meta.epacMetadata
204
+ }
205
+ $orderedMetadata = (ConvertTo-Json $orderedMeta - Depth 100 - Compress).ToString()
206
+ $array.Metadata = $orderedMetadata
201
207
}
202
- $orderedMetadata = (ConvertTo-Json $orderedMeta - Depth 100 - Compress).ToString()
203
- $array.Metadata = $orderedMetadata
204
208
}
205
209
$csvFile = " $stem .csv"
206
210
if (Test-Path $csvFile ) {
@@ -246,12 +250,14 @@ function Out-PolicyExemptions {
246
250
}
247
251
# Logic to force the order of the Metadata property (DeployedBy first, then epacMetadata)
248
252
foreach ($array in $jsonArray ) {
249
- $meta = $array.Metadata
250
- $orderedMeta = [ordered ]@ {
251
- deployedBy = $meta [' deployedBy' ]
252
- epacMetadata = $meta [' epacMetadata' ]
253
+ if ($null -ne $array.Metadata ) {
254
+ $meta = $array.Metadata
255
+ $orderedMeta = [ordered ]@ {
256
+ deployedBy = $meta [' deployedBy' ]
257
+ epacMetadata = $meta [' epacMetadata' ]
258
+ }
259
+ $array.Metadata = $orderedMeta
253
260
}
254
- $array.Metadata = $orderedMeta
255
261
}
256
262
$jsonFile = " $stem .$FileExtension "
257
263
if (Test-Path $jsonFile ) {
@@ -283,14 +289,16 @@ function Out-PolicyExemptions {
283
289
}
284
290
# Logic to force the order of the Metadata property (DeployedBy first, then epacMetadata)
285
291
foreach ($array in $excelArray ) {
286
- $metaString = $array.Metadata
287
- $meta = $metaString | ConvertFrom-Json - Depth 100
288
- $orderedMeta = [ordered ]@ {
289
- deployedBy = $meta.deployedBy
290
- epacMetadata = $meta.epacMetadata
292
+ if ($null -ne $array.Metadata ) {
293
+ $metaString = $array.Metadata
294
+ $meta = $metaString | ConvertFrom-Json - Depth 100
295
+ $orderedMeta = [ordered ]@ {
296
+ deployedBy = $meta.deployedBy
297
+ epacMetadata = $meta.epacMetadata
298
+ }
299
+ $orderedMetadata = (ConvertTo-Json $orderedMeta - Depth 100 - Compress).ToString()
300
+ $array.Metadata = $orderedMetadata
291
301
}
292
- $orderedMetadata = (ConvertTo-Json $orderedMeta - Depth 100 - Compress).ToString()
293
- $array.Metadata = $orderedMetadata
294
302
}
295
303
$csvFile = " $stem .csv"
296
304
if (Test-Path $csvFile ) {
0 commit comments