ConnectWiseControlAPI icon indicating copy to clipboard operation
ConnectWiseControlAPI copied to clipboard

Update Remove-CWCSession.ps1 to Correct JSON Format with multiple GUIDs

Open droorda opened this issue 9 months ago • 0 comments

Correct Format of Json object when submitting multiple GUID's

The Call allows Multiple GUIDs to be sent in a single call [guid[]]$GUID Currently when Multiple are passed the Created Json looks like

[
  [
    "All Machines"
  ],
  [
    {
      "EventType": 21,
      "SessionID": "719a6448-8713-447e-ad8d-47cbb504a2d5 3ad19bde-40da-4026-a5f7-82aa3bddad8b"
    }
  ]
]

which puts multiple GUIDs under a single session ID

This change creates JSON like [["All Machines"],[{"EventType":21,"SessionID":"719a6448-8713-447e-ad8d-47cbb504a2d5"},{"EventType":21,"SessionID":"3ad19bde-40da-4026-a5f7-82aa3bddad8b"}]] which matches the calls from the web client

Expanded for readability

[
  [
    "All Machines"
  ],
  [
    {
      "EventType":21,
      "SessionID":"719a6448-8713-447e-ad8d-47cbb504a2d5"
    },
    {
      "EventType":21,
      "SessionID":"3ad19bde-40da-4026-a5f7-82aa3bddad8b"
    }
  ]
]

droorda avatar Apr 15 '25 18:04 droorda