Getting Data In

How to enable and disable scheduled searches using Splunk REST API in Powershell?

vivekriyer
Explorer

I have a requirement to disable scheduled search (specific ones) during a specific window and when a data load runs, enable it back on once the load is completed.
I have a limitation of running it Powershell. I went through couple of Answers posts and was not able to find a post related to Powershell implementation.

Thanks in advance.

0 Karma
1 Solution

acharlieh
Influencer

I am not a powershell user... however it looks like there's a cmdlet to Invoke a HTTP Rest service, namely Invoke-RestMethod: https://technet.microsoft.com/en-us/library/hh849971.aspx

In fact the documentation on that page has an example of performing a POST request that's using the Splunk API to execute a Splunk search and getting results from it.

Armed with this, and the Splunk REST reference, it should be only minor modifications to the $Url and $Body arguments to then be able to modify your saved search (to schedule / unschedule it at whim): http://docs.splunk.com/Documentation/Splunk/6.4.3/RESTREF/RESTsearch#POST_saved.2Fsearches.2F.7Bname...

View solution in original post

acharlieh
Influencer

I am not a powershell user... however it looks like there's a cmdlet to Invoke a HTTP Rest service, namely Invoke-RestMethod: https://technet.microsoft.com/en-us/library/hh849971.aspx

In fact the documentation on that page has an example of performing a POST request that's using the Splunk API to execute a Splunk search and getting results from it.

Armed with this, and the Splunk REST reference, it should be only minor modifications to the $Url and $Body arguments to then be able to modify your saved search (to schedule / unschedule it at whim): http://docs.splunk.com/Documentation/Splunk/6.4.3/RESTREF/RESTsearch#POST_saved.2Fsearches.2F.7Bname...

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...