Skip to content

Instantly share code, notes, and snippets.

@snydergd
Created May 26, 2023 15:00
Show Gist options
  • Save snydergd/795ccc4dd8a5df92ae4cd03557cbae09 to your computer and use it in GitHub Desktop.
Save snydergd/795ccc4dd8a5df92ae4cd03557cbae09 to your computer and use it in GitHub Desktop.
PowerShell installer Script for Linux - to make installation/upgrade easier
#!/bin/bash
usage() {
echo "Usage: $0 <version> # version example: 7.4.0-preview.3" >&2;
}
if [ "$1x" = "x" ]; then
usage;
echo "No version supplied - using default" >&2;
VERSION="7.4.0-preview.3";
else
VERSION="$1";
fi;
DOWNLOAD_URL="https://github.com/PowerShell/PowerShell/releases/download/v${VERSION}/powershell-${VERSION}-linux-x64.tar.gz";
OUTPUT_FOLDER="${HOME}/pwsh/pwsh-${VERSION}";
LINK_FOLDER="${HOME}/pwsh/current";
if [ -e "${OUTPUT_FOLDER}" ]; then
echo "Folder ${OUTPUT_FOLDER} already exists. Not installing." >&2;
else
echo "Using version ${VERSION}";
mkdir -p "${OUTPUT_FOLDER}";
cd "${OUTPUT_FOLDER}";
curl -L "${DOWNLOAD_URL}" | tar -xzv;
fi;
echo "Creating symlink to ${OUTPUT_FOLDER} at ${LINK_FOLDER}" >&2;
ln -sf "${OUTPUT_FOLDER}" "${LINK_FOLDER}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment