<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Powershell script not running on schedule in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450039#M78135</link>
    <description>&lt;P&gt;I'm running 2 powershell scripts on an Universal Forwarder version 7.0.1 to get all the users and systems from the AD, I want them to run everyday at 12 am. I have the powershell add-on on the universal forwarder.&lt;BR /&gt;
For some reason the scripts are not running everyday, sometimes it works and sometimes it won't, usually after a restart it runs once and then the next day it's not running again.&lt;/P&gt;

&lt;P&gt;Their inputs in inputs.conf are:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell://Active-Directory]
script = . "C:\Program Files\SplunkUniversalForwarder\etc\apps\\systems.ps1"
schedule = 0 0 * * *
index = something

[powershell://Users]
script = . "C:\Program Files\SplunkUniversalForwarder\etc\apps\\users.ps1"
schedule = 0 0 * * *
index = something2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't find anything helpful in the logs or online. &lt;BR /&gt;
Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Sun, 22 Jul 2018 07:46:11 GMT</pubDate>
    <dc:creator>agentsofshield</dc:creator>
    <dc:date>2018-07-22T07:46:11Z</dc:date>
    <item>
      <title>Powershell script not running on schedule</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450039#M78135</link>
      <description>&lt;P&gt;I'm running 2 powershell scripts on an Universal Forwarder version 7.0.1 to get all the users and systems from the AD, I want them to run everyday at 12 am. I have the powershell add-on on the universal forwarder.&lt;BR /&gt;
For some reason the scripts are not running everyday, sometimes it works and sometimes it won't, usually after a restart it runs once and then the next day it's not running again.&lt;/P&gt;

&lt;P&gt;Their inputs in inputs.conf are:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell://Active-Directory]
script = . "C:\Program Files\SplunkUniversalForwarder\etc\apps\\systems.ps1"
schedule = 0 0 * * *
index = something

[powershell://Users]
script = . "C:\Program Files\SplunkUniversalForwarder\etc\apps\\users.ps1"
schedule = 0 0 * * *
index = something2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't find anything helpful in the logs or online. &lt;BR /&gt;
Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jul 2018 07:46:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450039#M78135</guid>
      <dc:creator>agentsofshield</dc:creator>
      <dc:date>2018-07-22T07:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell script not running on schedule</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450040#M78136</link>
      <description>&lt;P&gt;Hi @agentsofshield,&lt;/P&gt;

&lt;P&gt;you can directly invoke script like below, and your schedule syntax is wrong.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell://Active-Directory]
script= $SPLUNK_HOME\etc\apps\users.ps1
disabled = false
index = something
interval = 86400 
source = something
sourcetype = something
# interval : runs once in day
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell://Active-Directory]
 script= $SPLUNK_HOME\etc\apps\users.ps1
 disabled = false
 index = something
 schedule = */5 * * * *
 source = something
 sourcetype = something
 #schedule : runs for every 5 mins.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Jul 2018 10:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450040#M78136</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2018-07-22T10:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell script not running on schedule</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450041#M78137</link>
      <description>&lt;P&gt;Thanks for the answer, I changed the schedule to &lt;CODE&gt;schedule = 0 0 * * *&lt;/CODE&gt; and yesterday it worked fine but today only one script gave me events, do you know why?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 06:54:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450041#M78137</guid>
      <dc:creator>agentsofshield</dc:creator>
      <dc:date>2018-07-25T06:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell script not running on schedule</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450042#M78138</link>
      <description>&lt;P&gt;as per your cron it runs exactly midnight ( once in a full day). please check if it matches your schedules.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 06:58:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450042#M78138</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2018-07-25T06:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell script not running on schedule</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450043#M78139</link>
      <description>&lt;P&gt;It should run at midnight but it didn't run at all&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 10:09:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/450043#M78139</guid>
      <dc:creator>agentsofshield</dc:creator>
      <dc:date>2018-07-25T10:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell script not running on schedule</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/506125#M86199</link>
      <description>&lt;P&gt;I have been fighting with this issue for a long time. it doesn't seems possible to run 2 scripts simulations.&lt;/P&gt;&lt;P&gt;I had some success in doing a */5 * * * * on two scripts but still weird stuff happens&lt;/P&gt;&lt;P&gt;when restarting the service the first script always runs. then i waits 5 min and runs the second script and 5 min again for the second script, so its in sequence they run in my case .&lt;/P&gt;&lt;P&gt;You can from the Powershell.ps1 that splunk uses set a debug parameter to get more information.&amp;nbsp; try do an example with */2 * * * * and test for your self it should run both scripts each second minute, but it ends up taking 4 minute as its in sequence&lt;/P&gt;&lt;P&gt;My solution was to only have one cron and one script having multiply function inside. and then use the hardcoded splunk PSobject rows to define index, source, and sourcetype.&lt;/P&gt;&lt;P&gt;When you enable debug try this command to see when you scripts execute&lt;/P&gt;&lt;P&gt;Get-Content -Path 'C:\Program Files\SplunkUniversalForwarder\var\log\splunk\splunk-powershell.ps1.log' | Select-String -Pattern 'Executing script' | Out-GridView&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 09:34:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-not-running-on-schedule/m-p/506125#M86199</guid>
      <dc:creator>Danny_Nilsson</dc:creator>
      <dc:date>2020-06-25T09:34:55Z</dc:date>
    </item>
  </channel>
</rss>

