Created
July 5, 2017 16:18
-
-
Save MichaelRyom/480b4333790d7e0f3816f8246fd4e79f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#User varables | |
$LIhost = "10.10.10.10" #IP or FQDN | |
$Provider = "Local" #Local, ActiveDirectory | |
$Username = "admin" | |
$Password = "VMware1!" | |
#SSL certificate trust - Trust all certs | |
add-type @" | |
using System.Net; | |
using System.Security.Cryptography.X509Certificates; | |
public class TrustAllCertsPolicy : ICertificatePolicy { | |
public bool CheckValidationResult( | |
ServicePoint srvPoint, X509Certificate certificate, | |
WebRequest request, int certificateProblem) { | |
return true; | |
} | |
} | |
"@ | |
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy | |
#^End of SSL certificate trust | |
#Login to Log Insight - make creds as json | |
$creds = @{ | |
provider=$Provider | |
username=$Username | |
password=$Password | |
} | |
$json = $creds | ConvertTo-Json | |
#Get session infomation | |
$response = Invoke-RestMethod "https://$LIHost/api/v1/sessions" -Method POST -Body $json -ContentType "application/json" | |
#Create header infomation used when quering Log Insight | |
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" | |
$headers.Add("Authorization", "Bearer "+($response.sessionId)) | |
#Get data from Log Insight | |
$Query = Invoke-WebRequest -Uri "https://$LIHost/api/v1/events/" -Headers $Headers | |
#Display data | |
($Query.Content | ConvertFrom-Json).events |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment