Is it possible to write one script that runs in bash/shell and PowerShell?
<p>I need to create ONE integrated script that sets some environment variables, downloads a file using wget and runs it.</p>

<p>The challenge is that it needs to be the SAME script that can run on both Windows PowerShell and also bash / shell.</p>

<p>This is the shell script:</p>

<pre><code>#!/bin/bash
# download a script
wget http://www.example.org/my.script -O my.script
# set a couple of environment variables
export script_source=http://www.example.org
export some_value=floob
# now execute the downloaded script
bash ./my.script
</code></pre>

<p>This is the same thing in PowerShell:</p>

<pre><code>wget http://www.example.org/my.script -O my.script.ps1
$env:script_source="http://www.example.org"
$env:some_value="floob"
PowerShell -File ./my.script.ps1
</code></pre>

<p>So I wonder if somehow these two scripts can be merged and run successfully on either platform?</p>

<p>I've been trying to find a way to put them in the same script and get bash and PowerShell.exe to ignore errors but have had no success doing so.</p>

<p>Any guesses?</p>