Ubuntu (PowerShell)

From vwiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Installation

For the latest info, see https://docs.microsoft.com/en-us/powershell/scripting/install/install-ubuntu

apt install wget apt-transport-https software-properties-common
wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb

Path Permission Error

If you get the following error whenever running a command - Error reading or writing history file. Its likely PowerShell was installed as root, but you're now running as a standard user, do the following...

sudo pwsh
$refDir = Resolve-Path '~'
$dstDir = Resolve-Path '~/.local/share/powershell'
chown -R --reference=$refDir $dstDir
exit

Above came from https://github.com/PowerShell/PowerShell/issues/10601

Getting Started

To enter the PowerShell command line interface use the following command

pwsh

To run a PowerShell script

pwsh ./do-something.ps1