From a7768cc64d2070aa1d921ee1248a5731906bbf76 Mon Sep 17 00:00:00 2001 From: Hiren Shah <github@hirenshah.co.uk> Date: Wed, 17 Jan 2024 16:40:33 +0000 Subject: [PATCH] docs: Update remove-offline-files.md (#6449) The previous Windows Powershell script didn't work - resulted in a bunch of errors due to multiple reasons. The revised code works as expected. --- docs/docs/guides/remove-offline-files.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/docs/guides/remove-offline-files.md b/docs/docs/guides/remove-offline-files.md index e4665abac2..d3bca187d0 100644 --- a/docs/docs/guides/remove-offline-files.md +++ b/docs/docs/guides/remove-offline-files.md @@ -23,11 +23,15 @@ awk -F\" '/entityId/ {print $4}' orphans.json | while read line; do curl --locat ``` Get-Content orphans.json | Select-String -Pattern 'entityId' | ForEach-Object { -$line = line=$_ -split '"' | Select-Object -Index 3 -Invoke-RestMethod -Uri 'http://YOUR_IP_HERE:2283/api/asset' -Method Delete -Headers @{ -'Content-Type' = 'application/json' -'x-api-key' = 'YOUR_API_KEY_HERE' -} -Body "{"force": true, "ids": ["$line"]}" + $line = $_ -split '"' | Select-Object -Index 3 + $body = [pscustomobject]@{ + 'ids' = @($line) + 'force' = (' true ' | ConvertFrom-Json) + } | ConvertTo-Json -Depth 3 + Invoke-RestMethod -Uri 'http://YOUR_IP_HERE:2283/api/asset' -Method Delete -Headers @{ + 'Content-Type' = 'application/json' + 'x-api-key' = 'YOUR_API_KEY_HERE' + } -Body $body } ```