• Linux 安装 powershell


    linux 安装 powershell

    Intro

    powershell 已经推出了一个 Powershell Core, 版本号对应 Powershell 6.x,可以跨平台,支持 Linux 和 mac.
    这使得对于熟练使用 Powershell 进行开发运维的一些开发者来说无疑是个福音。

    今天就来在 Linux 上安装 powershell,以 centos7 为例介绍安装 powershell。

    PowerShell 和 PowerShell Core

    那Windows PowerShell与PowerShell Core 6.0又有什么区别呢,主要几个区别如下:

    • Windows PowerShell是基于.NET Framework的,所以它也只能在Windows中使用。
      PowerShell Core 6.0发布时,Windows PowerShell 最新的版本在5.*,但PowerShell Core 6.0 可不是Windows PowerShell的升级版本。
    • PowerShell Core 6.0因为它的跨平台,自然不仅可以在 Windows 上运行也可以在其它平台如macOS与Linux上运行,因为它是基于.NET Core基础之上的。
    • Windows PowerShell在 Windows 中的执行文件为powershell.exe,而PowerShell Core 6.0在Windows中的执行文件是pwsh.exe,在 macOS 和 Linux 中的执行文件是 pwsh

    PowerShell Core 平台支持情况

    PowerShell 现在官方支持 macOS 和 Linux,包括:

    • Windows 7、8.1 和 10
    • Windows Server 2008 R2、2012 R2、2016
    • Windows Server 半年频道
    • Ubuntu 14.04、16.04 和 17.04
    • Debian 8.7+ 和 9
    • CentOS 7
    • Red Hat Enterprise Linux 7
    • OpenSUSE 42.2
    • Fedora 25、26
    • macOS 10.12+

    我们社区也为以下平台提供包,但是它们不受正式支持:

    • Arch Linux
    • Kali Linux
    • AppImage(可在多个 Linux 平台上运行)

    我们还对以下平台提供试验版本(不受支持):

    • ARM32/ARM64 上的 Windows
    • Raspbian (Stretch)

    在 Linux上安装 PowerShell

    这里以 Centos 为例,介绍如何安装 PowerShell,其他 Linux 系统可以参考这里的文档

    这里有两种方式可以安装

    • 注册微软的镜像源(推荐)

      # Register the Microsoft RedHat repository
      curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
      
      # Install PowerShell
      sudo yum install -y powershell
      
      
    • 直接下载文件安装

      sudo yum install https://github.com/PowerShell/PowerShell/releases/download/v6.1.0/powershell-6.1.0-1.rhel.7.x86_64.rpm
      

    安装完成之后可以直接执行 pwsh 就可以进入 powershell 了,如果可以正常进入则证明安装成功了。

    卸载

    sudo yum remove powershell
    

    Reference

    Contact

    Contact me: weihanli@outlook.com

  • 相关阅读:
    几个基本trick
    CSP2019 树上的树 口胡
    To do List
    对代码风格的探索(持续更新)
    我回来了。
    年度悲剧
    最短路
    平衡树
    线段树-模板
    jmeter断言之JSON Assertion
  • 原文地址:https://www.cnblogs.com/weihanli/p/install-powershell-on-linux.html
Copyright © 2020-2023  润新知