terminal-linux-logo-1terminal-linux-logo-1在CentOS 8上安装PowerShell

步骤1.首先,让我们首先确保您的系统是最新的。

sudo clean all
sudo dnf update

步骤2.在CentOS 8上安装PowerShell。

适用于Linux的PowerShell已发布到官方的Microsoft存储库中,以便于安装和更新。

  • 使用RPM软件包安装PowerShell:

现在,我们将使用以下命令添加正式的Microsoft存储库:

curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

然后,运行以下命令以安装PowerShell:

sudo dnf install powershell

安装后,使用以下命令启动PowerShell:

root@idroot ~]# pwsh
  • 从Github安装PowerShell:

现在运行以下命令从Github安装PowerShell :

sudo dnf install https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/powershell-7.0.3-1.centos.8.x86_64.rpm

一旦安装成功,这就是PowerShell的基本用法:

root@idroot ~]# pwsh
PowerShell 7.0.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type \'help\' to get help.

PS /root># display Cmdlet list (only display 10 lines from the head)
PS /root> (Get-Command)[0..9]
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        cd..
Function        cd\\
Function        Clear-Host
Function        Compress-Archive                                   1.2.5      Microsoft.PowerShell.Archive
Function        Configuration                                      2.0.5      PSDesiredStateConfiguration
Function        Expand-Archive                                     1.2.5      Microsoft.PowerShell.Archive
Function        Find-Command                                       2.2.4.1    PowerShellGet
Function        Find-DSCResource                                   2.2.4.1    PowerShellGet
Function        Find-Module                                        2.2.4.1    PowerShellGet
Function        Find-RoleCapability                                2.2.4.1    PowerShellGet

恭喜你!您已经成功安装了PowerShell。感谢您使用本教程在CentOS 8系统上安装PowerShell Microsoft。有关其他帮助或有用信息,我们建议您检查PowerShell的官方网站。