NOTE: The following code may be out-of-date compared to GitHub, but is all pulled from GitHub every hour or so.
When shortlinks are used (filename as subdomain), code used by PowerShell and other interactions with this site is served from GitHub.
(Right-click -> Download the button below to save the file)
#!/bin/bash
echo -e "\033[33m--------------------------------------------------"
echo -e "Welcome to TroubleChute's PowerShell installer!"
echo -e "PowerShell should now be installed..."
echo -e "[Version 2023-06-06]\033[0m"
echo -e"This script is provided AS-IS without warranty of any kind. See https://tc.ht/privacy & https://tc.ht/terms."
echo -e "\033[32m\nConsider supporting these install scripts: https://tc.ht/support"
echo -e "\033[33m--------------------------------------------------\n\n\033[0m"
# IF LINUX:
if [[ "$(uname -s)" == "Linux" ]]; then
# Check if Apt is available to install and use lsb-release to get OS information
if command -v apt-get >/dev/null 2>&1; then
echo -e "\033[36mApt detected. Attempting to install lsb-release to check version info...\033[0m"
apt-get update && apt-get install -y lsb-release && apt-get clean all
if [[ -f "/etc/lsb-release" ]]; then
. /etc/lsb-release
if [[ "$DISTRIB_ID" == "Ubuntu" ]]; then
echo -e "\033[36mUbuntu detected.\033[0m"
# Install PowerShell - https://learn.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.3
# Install pre-requisite packages.
apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
# Register the Microsoft repository GPG keys
dpkg -i packages-microsoft-prod.deb
# Delete the the Microsoft repository GPG keys file
rm packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
apt-get update
# Install PowerShell
apt-get install -y powershell
# Start PowerShell
pwsh
elif [[ "$ID" == "debian" ]]; then
echo -e "\033[36mDebian detected.\033[0m"
# Install for Debian https://learn.microsoft.com/en-us/powershell/scripting/install/install-debian?view=powershell-7.3
if [[ "$VERSION_ID" == "11" ]]; then
echo -e "\033[36mDebian 11 to be specific.\033[0m"
# Install system components
apt update && apt install -y curl gnupg apt-transport-https
# Import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
# Register the Microsoft Product feed
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list'
# Install PowerShell
apt update && apt install -y powershell
# Start PowerShell
pwsh
elif [[ "$VERSION_ID" == "10" ]]; then
echo -e "\033[36mDebian 10 to be specific.\033[0m"
# Download the Microsoft repository GPG keys
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
dpkg -i packages-microsoft-prod.deb
# Update the list of products
apt-get update
# Install PowerShell
apt-get install -y powershell
# Start PowerShell
pwsh
else
echo -e "\033[36mUnknown Debian version...\033[0m"
echo "This script is only for Debian 11 or Debian 10"
fi
elif [[ "$ID" == "raspbian" || "$ID" == "debian" ]]; then
echo -e "\033[36mRaspbian detected.\033[0m"
# Install for Raspbian https://learn.microsoft.com/en-us/powershell/scripting/install/install-raspbian?view=powershell-7.3
if [[ "$VERSION_ID" =~ (9|10) ]]; then
echo -e "\033[36mRaspbian 9 or 10 detected.\033[0m"
# Prerequisites
apt-get update
apt-get install '^libssl1.0.[0-9]