7.8 C
New York
Friday, January 12, 2024

The Common PowerShell Core Installer (Set up-PowerShell.sh)


Since PowerShell Core was introduced not fairly a 12 months in the past, I’ve had a shocking variety of causes emigrate or refit current PowerShell code to run on PowerShell Core. In some circumstances preserving future improvement suitable with each environments provides strategic worth.

The PowerShell Core undertaking on github did have an early model of a multi-distro installer, however it required guide tweaks to be up to date for every new launch and was not utilizing the repository hyperlinks Microsoft has been placing up.

I imagine the flexibility to shortly setup a sandbox atmosphere is a important functionality for the adoption of any new expertise. So, inside the PowerShell Core open supply undertaking, I got down to construct a common installer that might be used to get the most recent model, from repositories (to make updates simpler) and optionally set up a improvement atmosphere consisting of Visible Studio Code and the VS Code PowerShell Extension.

The time period “Design Objectives” makes it sound like they’re both completed or not, when in actuality many design priorities are “fascinating in various levels”.

  • Runs headless by default – no enter required (if acceptable permissions are possessed by the launching course of).
  • Runs instantly from the Web
  • May be downloaded to run regionally (then solely the repo touches will want the Web)
  • Makes use of lowest widespread runtime necessities that must be on each distro.
  • Is extensible to assist different distro households as they’re examined for compatibility with PowerShell Core.
  • Is straightforward to make use of as a template for creating personalized installers for particular or proprietary use circumstances.
  • The common installer calls per-distro-family sub-installers you could name instantly whenever you already know the distro. So if you wish to share the installer with everybody in your organization, no matter what they’ll set up it on, you level them to install-powershell.sh. If, nonetheless, you might be sending it out to a bunch OSX machines, you possibly can pull installpsh-osx.sh as a substitute.
  • when install-powershell.sh searches for sub-scripts it robotically prefers native copies (however resorts to pulling from github if there is no such thing as a native) – this permits curation of the scripts so you possibly can have a number of of those advantages:
    1. guarantee 100% availability of the script (don’t depend upon github),
    2. evaluate safety of the code,
    3. lock your automation to a identified working model of the code,
    4. enable use in environments the place the web just isn’t out there,
    5. customise the code to your liking,
    6. enable working when your system safety settings don’t allow scripts to be executed instantly from community sources.

Desktop environments have been examined so as to set up and check VS Code, however this concurrently assessments that PowerShell Core may be put in by iteslf on these distros with no desktop atmosphere.

  • Ubuntu Desktop 16.04
  • CentOS 7.2 with GNOME Desktop
  • OpenSuSE 42.2 with KDE Desktop
  • OSX
  • bash shell
  • sed
  • curl (auto-installed if lacking)
  • platform’s native bundle supervisor with Web entry to repos (e.g. yum on CentOS, apt-get on Ubuntu, homebrew on OSX)
  • wget or curl to kick off net primarily based installer (with web entry)

The set up command line can also be in feedback on the high of the set up script – so they’re all the time simple to seek out. Curl can be utilized rather than wget – see the script feedback for examples.

You need to all the time study any web sourced code you’re going to run earlier than you run it, you possibly can evaluate install-powershell.sh and it’s sub-scripts (installpsh*.sh) right here: https://github.com/PowerShell/PowerShell/tree/grasp/instruments

The installer helps the next switches:

  • no switches – robotically installs PowerShell Core engine solely.
  • -includeide – installs Visible Studio Code and the PowerShell Extension
  • -interactivetesting – run some set up assessments (requires human interplay and remark)

Oneliner Set up Solely PowerShell Core on No matter Distro is Working

bash <(wget -O - https:

Oneliner Set up PowerShell Core and Visible Studio Code with PowerShell Extension (for improvement machines – requires a desktop enviroment)

bash <(wget -O - https:

Oneliner Set up PowerShell Core with IDE and Do Some Interactive Checks (human interplay required)

bash <(wget -O - https:

In case you have any contributions or solutions for this installer, remember to create a difficulty on the PowerShell Venture right here https://github.com/powershell/powershell/points and point out @DarwinJS to get my consideration.

In case you are looking for assist for an a brand new distro or OS model the installer does assist, it is rather useful when you:

  1. Determine that you’ve got examined PowerShell to really work on that distro or model.
  2. Determine the precise distro, distro household and model you examined on.
  3. Describe the use case (why putting in PowerShell on this specific distro is helpful to you).

It’s most useful to have a duplicate of examined code in a pull request (or recorded within the problem itself when you would not have the time for a pull request). The reason being that it may be very difficult to create check environments for all of the variations to check that engineered code is working as anticipated – however, against this, it might be very simple so that you can present such code when you’ve already constructed it.

The code can also be developed in a means that ought to make it pretty simple to create your personal installer for proprietary or edge case conditions that it could not make sense to work into the open supply installer.

This installer is now being utilized by the PowerShell Core steady integration pipeline to put in PowerShell core in preparation for testing the most recent launch.

PowerShell Open Supply Venture: https://github.com/PowerShell/PowerShell



Supply hyperlink

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles