Deployment Architecture

Error when sending windows events to splunk enterprise using powershell

991423214
New Member

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

Labels (1)
0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@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!!!

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...