# 判断 PowerShell 是否已安装 if [ "$OS" == "windows" ]; then if ! command -v powershell.exe &> /dev/null; then echo "PowerShell 未安装,正在安装 PowerShell..." # 检查系统位数 if [ "$(uname -m)" == "x86_64" ]; then # 下载 64 位 PowerShell 安装程序 curl -o PowerShellInstaller.exe -L https://raw.githubusercontent.com/CW-Khristos/scripts/master/PowerShell/PowerShell-7.1.4-win-x64.msi else # 下载 32 位 PowerShell 安装程序 curl -o PowerShellInstaller.exe -L https://raw.githubusercontent.com/CW-Khristos/scripts/master/PowerShell/PowerShell-7.1.4-win-x86.msi fi # 等待下载完成 while [ ! -f PowerShellInstaller.exe ]; do sleep 1 done # 安装 PowerShell ./PowerShellInstaller.exe /quiet # 删除安装程序 rm PowerShellInstaller.exe echo "PowerShell 安装完成!" else echo "PowerShell 已安装!" fi fi
标签:shell,PowerShellInstaller,PowerShell,exe,安装程序,echo,安装,powershell From: https://www.cnblogs.com/siyunianhua/p/17988693