Use additional log analytics workspaces in KQL script

Michel Sfeir 190 Reputation points
2025-04-16T09:01:58.2+00:00

Hello,

I'm trying to execute a KQL that retrieves the applications installed on the VMs, but i cannot seem to search in all workspaces dynamically (I want to avoid listing the workspaces manually). I don't know if the parameter "-AdditionalWorkspaces" is recognized in the below query.

$result = Invoke-AzOperationalInsightsQuery `

-WorkspaceId $primaryWorkspace.CustomerId `

-Query $query `

-AdditionalWorkspaces $additionalWorkspaceIDs

Thank you,

Michel

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,565 questions
{count} votes

Accepted answer
  1. Clive Watson 7,481 Reputation points MVP
    2025-04-16T13:15:56.7066667+00:00

    The function workspace("xxxxxxxxxxx") doesn't allow a variable so you have to hard code these

    You could consider doing this query from within a Azure Monitor Workbook as that allows you to query any selected / visible workspace.

    User's image

    Otherwise using a Logic App or even the api's to enumerate through workspaces


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.