rpm安装
下载地址: https://github.com/PowerShell/PowerShell
下载文件: powershell-lts-7.2.7-1.rh.x86_64.rpm
安装:rpm -ivh powershell-lts-7.2.7-1.rh.x86_64.rpm
yum安装
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo
yum install -y powershell
查看系统支持的脚本
# 查看系统支持的脚本
cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/bin/tcsh
/bin/csh
/usr/bin/pwsh
# 执行脚本
pwsh
PowerShell 7.2.7
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
PS /root>
执行脚本文件(hello.ps1)
#!/usr/bin/pwsh
$i = 1
echo $i
echo "hello world~"
~
执行:./hello.ps1