You have to select the workspace ID ($workspace.CustomerId
), not the whole object ($workspace
).
$workspace = Get-AzoperationalInsightsWorkspace `
-Name *******-cac-ws-security-01 `
-ResourceGroupName *******-cac-rg-security-logs-01
I changed the variable name in your question from "$workspaceid" into "$workspace" without changing what's in it. And assume you've defined $query
for the same KQL query.
Then run a very similar command:
Invoke-AzOperationalInsightsQuery -Query $query -WorkspaceId $workspace.CustomerId