@@ -156,6 +156,15 @@ function Out-PolicyExemptions {
156
156
if ($selectedArray -and $selectedArray.Count -gt 0 ) {
157
157
$jsonArray += $selectedArray
158
158
}
159
+ # Logic to force the order of the Metadata property (DeployedBy first, then epacMetadata)
160
+ foreach ($array in $jsonArray ) {
161
+ $meta = $array.Metadata
162
+ $orderedMeta = [ordered ]@ {
163
+ deployedBy = $meta [' deployedBy' ]
164
+ epacMetadata = $meta [' epacMetadata' ]
165
+ }
166
+ $array.Metadata = $orderedMeta
167
+ }
159
168
$jsonFile = " $stem .$FileExtension "
160
169
if (Test-Path $jsonFile ) {
161
170
Remove-Item $jsonFile
@@ -182,6 +191,17 @@ function Out-PolicyExemptions {
182
191
if ($null -ne $selectedArray -and $selectedArray.Count -gt 0 ) {
183
192
$excelArray += $selectedArray
184
193
}
194
+ # Logic to force the order of the Metadata property (DeployedBy first, then epacMetadata)
195
+ 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
201
+ }
202
+ $orderedMetadata = (ConvertTo-Json $orderedMeta - Depth 100 - Compress).ToString()
203
+ $array.Metadata = $orderedMetadata
204
+ }
185
205
$csvFile = " $stem .csv"
186
206
if (Test-Path $csvFile ) {
187
207
Remove-Item $csvFile
@@ -224,6 +244,15 @@ function Out-PolicyExemptions {
224
244
if ($selectedArray -and $selectedArray.Count -gt 0 ) {
225
245
$jsonArray += $selectedArray
226
246
}
247
+ # Logic to force the order of the Metadata property (DeployedBy first, then epacMetadata)
248
+ foreach ($array in $jsonArray ) {
249
+ $meta = $array.Metadata
250
+ $orderedMeta = [ordered ]@ {
251
+ deployedBy = $meta [' deployedBy' ]
252
+ epacMetadata = $meta [' epacMetadata' ]
253
+ }
254
+ $array.Metadata = $orderedMeta
255
+ }
227
256
$jsonFile = " $stem .$FileExtension "
228
257
if (Test-Path $jsonFile ) {
229
258
Remove-Item $jsonFile
@@ -252,6 +281,17 @@ function Out-PolicyExemptions {
252
281
if ($null -ne $selectedArray -and $selectedArray.Count -gt 0 ) {
253
282
$excelArray += $selectedArray
254
283
}
284
+ # Logic to force the order of the Metadata property (DeployedBy first, then epacMetadata)
285
+ 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
291
+ }
292
+ $orderedMetadata = (ConvertTo-Json $orderedMeta - Depth 100 - Compress).ToString()
293
+ $array.Metadata = $orderedMetadata
294
+ }
255
295
$csvFile = " $stem .csv"
256
296
if (Test-Path $csvFile ) {
257
297
Remove-Item $csvFile
0 commit comments