Using powershell on linux
Date: 2022-12-23Last modified: 2023-02-17
Photo by Derek Oyen on Unsplash
Table of contents
Installation — github — latest
Download latest version of install package from https://github.com/PowerShell/PowerShell/releases.
For Debian like distribution use dpkg -i
to install:
dpkg -i /tmp/powershell-preview_7.4.0-preview.1-1.deb_amd64.deb
Installation — github — stable version
Download stable version of install package from https://github.com/PowerShell/PowerShell/releases.
For Debian like distribution use dpkg -i
to install:
dpkg -i /tmp/powershell_7.2.9-1.deb_amd64.deb
Installation — Debian repository
sudo apt update && sudo apt install -y curl gnupg apt-transport-https
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" \
> /etc/apt/sources.list.d/microsoft.list'
sudo apt update && sudo apt install -y powershell
How to run
To launch PowerShell use the command pwsh-preview
, powershell
or pwsh
depending on version you have installed:
Preview version:
$ pwsh-preview
PowerShell 7.4.0-preview.1
PS /home/geraldo>
Stable version:
$ pwsh
PowerShell 7.2.9
PS /home/geraldo>
Finding Modules
PS /home/geraldo> Find-Module *sharepoint*
Version Name Repository Description
------- ---- ---------- -----------
16.0.23109.12000 Microsoft.Online.SharePoint.PowerS… PSGallery Microsoft SharePoint Online Services Module for Windows PowerShell
3.29.2101.0 SharePointPnPPowerShellOnline PSGallery Microsoft 365 Patterns and Practices PowerShell Cmdlets for SharePoint Online
5.3.0 SharePointDSC PSGallery This DSC module is used to deploy and configure SharePoint Server 2013, 2016 and 2019, and co…
0.12.0.0 xSharePoint PSGallery This DSC module is used to deploy and configure SharePoint Server 2013, and convers a wide ra…
3.29.2101.0 SharePointPnPPowerShell2016 PSGallery Microsoft 365 Patterns and Practices PowerShell Cmdlets for SharePoint 2016
3.29.2101.0 SharePointPnPPowerShell2013 PSGallery Microsoft 365 Patterns and Practices PowerShell Cmdlets for SharePoint 2013
3.29.2101.0 SharePointPnPPowerShell2019 PSGallery Microsoft 365 Patterns and Practices PowerShell Cmdlets for SharePoint 2019
1.0.0.98 RED-SharePoint PSGallery SharePoint PowerShell Module, Codename: RED
1.0.7 SharePointOnline.CSOM PSGallery This module allows the usage oft the SharePoint Online Client Side Object Model (CSOM) librar…
2.1.0 SCOrchDev-SharePoint PSGallery Integration to SharePoint lists using their REST interface
1.2.0 SharePoint.Password.Manager PSGallery Update SharePoint service account password and Workflow service account password
...
Installing modules
PS /home/geraldo> Install-Module SharePointPnPPowerShellOnline
PS /home/geraldo> Get-InstalledModule
Importing modules
PS /home/geraldo> Import-Module -DisableNameChecking SharePointPnPPowerShellOnline
Powershell ISE
- ISE — Integrated Scripting environment
- Is a host application that assists us to create a script, and to run, test, or debug a command or script.
- It can extend the scripting capabilities and provides a Windows-oriented graphical user interface(GUI) where users can run various commands.
- Provides numerous features such as saves time, improves debugging and testing, etc.
Basic commands
CMD | Powershell | Description |
---|---|---|
dir |
Get-Children |
List files and folders |
pwd |
Get-Location |
Current folder |
echo |
Write-Output |
print text on screen |
cls |
Clean-Host |
Clear screen |
cd |
Set-Location |
Change directory |
Get-Command
List all command, cmdlet, aliases, function, workflow, filter, and application installed on host.
Get-Command -Name "*pattern*"