using powershell can I get the ids of the current ...
# ask-ai
b
using powershell can I get the ids of the current agents into a variable, please show me how.
t
Thanks for reaching out, Jannik. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Which agents do you mean by "current agents" — LiveKit server workers, room participants (peers), OS-level service agents, or another system? Also tell me: • Where are the agents listed or exposed (API endpoint, local process list, database)? • Do you need IDs from a remote LiveKit instance or from the machine you're running PowerShell on? With that I’ll provide a targeted PowerShell snippet to store the IDs in a variable.
b
I mean from the return of lk agent list, it seems it is not able to output as json, so can you show me how to get the id of the agents into a variable.
t
Thanks — you mean parsing the plain-text table from
lk agent list
. Below is a concise PowerShell snippet that captures that output, extracts the first column (Agent ID) and stores IDs in `$agentIds`:
Copy code
# run command and keep only table lines that contain column separators
$tableLines = lk agent list | Where-Object { $_ -match '│' }

$agentIds = @()
foreach ($line in $tableLines) {
  # normalize spacing and split on the column separator
  $cols = ($line -replace '^\s*│\s*','' -replace '\s*│\s*$','') -split '│'
  # first column is the ID; trim and skip header/border rows
  $id = $cols[0].Trim()
  if ($id -and $id -ne 'ID') { $agentIds += $id }
}

# show collected IDs
$agentIds
If your
lk
output uses different characters or spacing, paste a sample of the output and I’ll adjust the parser. Would you like the IDs as a comma string or kept as an array? Sources: Agent deployment CLI reference | LiveKit docs