|
<h1>PowerShell</h1>
|
|
<p>You can use <a href="https://msdn.microsoft.com/en-us/powershell/mt173057.aspx">PowerShell</a>
|
|
and Windows Task Scheduler to automate various tasks on a Windows system.
|
|
From within a PowerShell script, it is also easy to ping SITE_NAME.</p>
|
|
<p>Here is a simple PowerShell script that pings SITE_NAME. When scheduled to
|
|
run with Task Scheduler, it will essentially just send regular "I'm alive" messages.
|
|
Of course, you can extend it to do more things.</p>
|
|
<div class="highlight"><pre><span></span><code><span class="c"># inside a PowerShell script:</span>
|
|
<span class="nb">Invoke-RestMethod</span> <span class="n">PING_URL</span>
|
|
</code></pre></div>
|
|
|
|
<p>Save the above to e.g., <code>C:\Scripts\healthchecks.ps1</code>.
|
|
Then use the following command in a Scheduled Task to run the script:</p>
|
|
<div class="highlight"><pre><span></span><code>powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
|
|
</code></pre></div>
|
|
|
|
<p>In simple cases, you can also pass the script to PowerShell directly,
|
|
using the "-command" argument:</p>
|
|
<div class="highlight"><pre><span></span><code># Without an underlying script, passing the command to PowerShell directly:
|
|
powershell.exe -Command <span class="s2">"&{Invoke-RestMethod PING_URL}"</span>
|
|
</code></pre></div>
|