<?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 Re: How can I get a PowerShell script to run at startup and every day thereafter? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488036#M83539</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;interval&lt;/CODE&gt; does not work for specific powershell stanzas.  You can set it for the modular input as a whole like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell]
interval = 60
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that just specifies how frequently Splunk tries to run &lt;CODE&gt;splunk-powershell.exe&lt;/CODE&gt;, just as with all the other Windows modular inputs (and like a lot of the other modular inputs, if there are any specific stanzas defined, then the modular input executable will run continuously, and only be restarted if it crashes, say).&lt;/P&gt;

&lt;P&gt;In terms of what you'd like to achieve, it is possible, albeit in a slightly hacky way.  What you basically need to do is to use two stanzas; e.g.:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell://LocalAdministrators-AtStart]
script = &amp;amp; "$SplunkHome\etc\apps\win_scripts\bin\LocalAdministrators.ps1"

[powershell://LocalAdministrators-EveryDay]
script = &amp;amp; "$SplunkHome\etc\apps\win_scripts\bin\LocalAdministrators.ps1"
schedule = 86400
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Not specifying &lt;CODE&gt;schedule&lt;/CODE&gt; means that the script is only run once.)&lt;/P&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;

&lt;P&gt;- Jo.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Sep 2019 12:33:34 GMT</pubDate>
    <dc:creator>jhornsby_splunk</dc:creator>
    <dc:date>2019-09-20T12:33:34Z</dc:date>
    <item>
      <title>How can I get a PowerShell script to run at startup and every day thereafter?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488035#M83538</link>
      <description>&lt;P&gt;How can I set a PowerShell script to run on startup and every 24 hours thereafter on a UF?  I have tried using &lt;CODE&gt;interval&lt;/CODE&gt; and &lt;CODE&gt;schedule&lt;/CODE&gt;.  Most of my UFs are 7.1.4 but there are some older 6.6 UFs floating around.&lt;/P&gt;

&lt;P&gt;If I only use &lt;CODE&gt;interval&lt;/CODE&gt;, it will run at startup, but not at any interval.&lt;BR /&gt;
If I only use &lt;CODE&gt;schedule&lt;/CODE&gt;, it will run on the schedule, either using time in seconds or cron, but not at startup.&lt;BR /&gt;
If I use &lt;CODE&gt;interval&lt;/CODE&gt; and &lt;CODE&gt;schedule&lt;/CODE&gt;, it will only follow the schedule parameter.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell://LocalAdministrators]
disabled = 0
script = &amp;amp; "$SplunkHome\etc\apps\win_scripts\bin\LocalAdministrators.ps1"
interval = 86400
schedule = 86400
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 17:55:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488035#M83538</guid>
      <dc:creator>54638</dc:creator>
      <dc:date>2019-09-19T17:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a PowerShell script to run at startup and every day thereafter?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488036#M83539</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;interval&lt;/CODE&gt; does not work for specific powershell stanzas.  You can set it for the modular input as a whole like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell]
interval = 60
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that just specifies how frequently Splunk tries to run &lt;CODE&gt;splunk-powershell.exe&lt;/CODE&gt;, just as with all the other Windows modular inputs (and like a lot of the other modular inputs, if there are any specific stanzas defined, then the modular input executable will run continuously, and only be restarted if it crashes, say).&lt;/P&gt;

&lt;P&gt;In terms of what you'd like to achieve, it is possible, albeit in a slightly hacky way.  What you basically need to do is to use two stanzas; e.g.:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[powershell://LocalAdministrators-AtStart]
script = &amp;amp; "$SplunkHome\etc\apps\win_scripts\bin\LocalAdministrators.ps1"

[powershell://LocalAdministrators-EveryDay]
script = &amp;amp; "$SplunkHome\etc\apps\win_scripts\bin\LocalAdministrators.ps1"
schedule = 86400
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Not specifying &lt;CODE&gt;schedule&lt;/CODE&gt; means that the script is only run once.)&lt;/P&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;

&lt;P&gt;- Jo.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 12:33:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488036#M83539</guid>
      <dc:creator>jhornsby_splunk</dc:creator>
      <dc:date>2019-09-20T12:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a PowerShell script to run at startup and every day thereafter?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488037#M83540</link>
      <description>&lt;P&gt;"Hacky" solution it is, since it appears to meet my needs in my testing.&lt;/P&gt;

&lt;P&gt;Thanks for the information on &lt;CODE&gt;interval&lt;/CODE&gt;. I started trying use that because Splunk Support told me to...&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 13:37:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488037#M83540</guid>
      <dc:creator>54638</dc:creator>
      <dc:date>2019-09-20T13:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a PowerShell script to run at startup and every day thereafter?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488038#M83541</link>
      <description>&lt;P&gt;Great!  Glad to hear it worked for you!  &amp;amp;:)&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 13:43:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-a-PowerShell-script-to-run-at-startup-and-every/m-p/488038#M83541</guid>
      <dc:creator>jhornsby_splunk</dc:creator>
      <dc:date>2019-09-20T13:43:47Z</dc:date>
    </item>
  </channel>
</rss>

