This is an example template. It has a batch script for downloading the latest release version of PowerShell from GitHub, and a batch script to run a PowerShell script with that version of PowerShell.
I've seen a few environments where upgrading PowerShell isn't an option for one reason or another. This gives the option to not have to upgrade PowerShell and yet still use the latest version of PowerShell. Allowing you to run PowerShell scripts with thier own packaged version of PowerShell. From my testing .Net 5.0 isn't required as the PowerShell zip from Github comes with everything needed to run it.
- PowerShell 2.0 or greater
- Server 2008 or greater
- A little bit of Batch and PowerShell knowledge to get a PowerShell script to run
- Copy the files in this repository into a folder
- Navigate to that folder
- Double click on
DownloadPowerShell.bat
or runDownloadPowerShell.ps1
in a PowerShell(version 5.1 or less) session - Wait for PowerShell to download and extract into the
PowerShell\
folder - Double click on
RunExample.bat
- You should see the output of
$PSVersionTable
- Do the steps above from 1 to 4
- Edit and Rename
RunExample.bat
andExample.ps1
as needed - Delete
PowerShell.zip
andDownloadPowerShell.bat
and/orDownloadPowerShell.ps1
- Zip your
bat
andps1
files, and thePowerShell
folder - Move your zip file to production
- Extract and run your
bat
file