VMware Cloud Community
SBooker
Contributor
Contributor

Powershell to export results of a query

Hi,

I'm trying to add Log Insight intelligence into my automation model. I want to be able to automate the exportation of results from a log insight query into a powershell environment. I've not yet found a way to do this.

I'm hoping someone can point me in the right direction.

Thanks,

Shane

Tags (2)
Reply
0 Kudos
2 Replies
billrothjr
VMware Employee
VMware Employee

My recommendation is to help us by giving us more info on what you need. Check out our features site for LI.

There is already a powershell idea: http://loginsight.vmware.com/a/dtd/connect-vRO-or-PowerShell-Host-for-actions/163963-24427

If this is close to yours, then vote for it, and/or provide more details. If not, write your own! Smiley Happy

br

------
Bill Roth, VMware
Reply
0 Kudos
MichaelRyom
Hot Shot
Hot Shot

Here you go, a simple example. First line authenticates and get a session id, which is used in the next line to get events. Hope this helps.

$Auth = Invoke-WebRequest -Uri https://192.168.199.8/api/v1/sessions -Method Post -Headers @{"Content-Type"="application/json"} -Body '{"provider":"Local", "username":"admin", "password":"password"}'
$data = Invoke-WebRequest -Uri https://192.168.199.8/api/v1/events -Method Get -Headers @{"X-LI-Session-Id"=($Auth.Content.Split(":|,")[3])}

Blogging at https://MichaelRyom.dk
Reply
0 Kudos