-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpowershell.sh
More file actions
executable file
·46 lines (33 loc) · 1.51 KB
/
powershell.sh
File metadata and controls
executable file
·46 lines (33 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
set -euo pipefail
trap "echo 'error: Script failed: see failed command above'" ERR
DIR=$(cd "$(dirname "$0")" && pwd)
source "$DIR/.lib.sh"
# https://docs.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.2#installation-via-package-repository
# apt-cache madison powershell | head -n 40
# apt list update && apt list -a powershell
start "PowerShell"
###################################
# Prerequisites
# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Get the version of Ubuntu
source /etc/os-release
# Download the Microsoft repository keys
wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb
# Register the Microsoft repository keys
sudo dpkg -i packages-microsoft-prod.deb
# Delete the Microsoft repository keys file
rm packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
###################################
# Install PowerShell
sudo apt-get install -y powershell
# Install modules
pwsh --command "Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted'"
pwsh --command "Install-Module -Name posh-git, PSReadLine, Microsoft.PowerShell.SecretManagement, Microsoft.PowerShell.SecretStore"
pwsh --command "Get-Module -Name posh-git, PSReadLine, Microsoft.PowerShell.SecretManagement, Microsoft.PowerShell.SecretStore -ListAvailable"
end 'pwsh' '--version'