I am trying to send events from my host machine to splunk using HEC.
My Function:
Invoke-RestMethod -Method Post -Uri $hecUri -Headers @{"Authorization" = "Splunk $hecToken"} -Body $jsonEventData -ContentType "application/json"
Error:
Invoke-RestMethod : Unable to connect to the remote server
At C:\Users\myusername\OneDrive\Desktop\Lab3.ps1:29 char:1
+ Invoke-RestMethod -Method Post -Uri $hecUri -Headers @{"Authorization ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : System.Net.WebException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
@991423214 - There aren't a lot of details in your error messages. But below line suggest there could possibly be a connectivity issue between your machine and Splunk.
At C:\Users\myusername\OneDrive\Desktop\Lab3.ps1:29 char:1
Also, I see you are trying to send events via HEC (Http Event Collector). Have you enabled the HEC from Global settings?
I hope this helps!! Kindly upvote if it does!!!