Ubuntu (PowerShell)

From vwiki
Revision as of 13:19, 5 December 2021 by Sstrutt (talk | contribs) (Added Path Permission Error)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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