shell安装powershell.exe

# 判断 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

 

posted @ 2024-01-26 09:56  韩梦芫  阅读(42)  评论(0编辑  收藏  举报