From 6349d99f16d3b1165292e46e3f28ad59ee5fd145 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Thu, 12 Nov 2026 10:09:41 +0100 Subject: [PATCH] Seed-Offerings.ps1: JSON-array expliciet opsommen (PowerShell 5.1) Co-Authored-By: Claude Sonnet 5.5 --- scripts/Seed-Offerings.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/Seed-Offerings.ps1 b/scripts/Seed-Offerings.ps1 index 124855a..f2131cb 100644 --- a/scripts/Seed-Offerings.ps1 +++ b/scripts/Seed-Offerings.ps1 @@ -73,7 +73,9 @@ finally { $headers = @{ Authorization = "Bearer $($login.accessToken)" } # The public list tells which slugs exist already. -$existing = @(Invoke-RestMethod -Method Get -Uri "$api/offerings" -Headers $headers | ForEach-Object { $_.slug }) +# Windows PowerShell 5.1 hands a JSON array over as ONE object; wrap it so every item is enumerated. +$list = @(Invoke-RestMethod -Method Get -Uri "$api/offerings" -Headers $headers) +$existing = @(foreach ($o in $list) { $o.slug }) foreach ($p in $packages) { if ($existing -contains $p.slug) { Write-Host "skip $($p.slug) (exists)"; continue } @@ -98,4 +100,5 @@ foreach ($p in $packages) { } Write-Host 'Result:' -Invoke-RestMethod -Method Get -Uri "$api/offerings" | ForEach-Object { Write-Host (" {0,2} {1} {2} [{3}]" -f $_.displayOrder, $_.slug, $_.price, $_.layout) } +$final = @(Invoke-RestMethod -Method Get -Uri "$api/offerings") +foreach ($o in $final) { Write-Host (" {0,2} {1} {2} [{3}]" -f $o.displayOrder, $o.slug, $o.price, $o.layout) }