You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux环境下静默安装PowerShell模块无法隐藏进度提示问题

$ProgressPreference 设置不生效是因为旧版 PowerShellGet 模块在 Linux 环境下的进度输出未对接 PowerShell 标准进度流,可通过以下方法实现完全静默安装:

方案1:追加静默专用参数

在安装命令中同时添加 -Quiet、-Force 以及流重定向配置,写法如下:

$ProgressPreference = 'SilentlyContinue'
Install-Module -Name <替换为你的模块名> -Scope CurrentUser -Quiet -Force -AllowClobber -AcceptLicense *>$null

参数说明:

  • -Quiet:专门抑制PowerShellGet命令的进度输出
  • -Force:跳过版本校验等提示直接安装
  • -AcceptLicense:自动同意模块的许可协议
  • *>$null:将所有输出流全部重定向至空,彻底消除各类冗余提示

方案2:先升级PowerShellGet到最新版本

旧版本PowerShellGet存在静默参数不生效的已知bug,先升级内置模块再执行安装即可:

$ProgressPreference = 'SilentlyContinue'
# 先升级PowerShellGet
Install-Module -Name PowerShellGet -Scope CurrentUser -Force -AllowClobber -Quiet -AcceptLicense *>$null
# 升级完成后安装目标模块
Install-Module -Name <替换为你的模块名> -Scope CurrentUser -Quiet -Force -AcceptLicense *>$null

注意事项

  • 如果需要全局安装所有用户可用的模块,将 -Scope CurrentUser 替换为 -Scope AllUsers,且需要以root权限运行PowerShell
  • 若安装非信任仓库的模块,可追加 -AllowPrerelease 允许安装预览版,追加 -Repository <仓库名> 指定模块来源

内容的提问来源于stack exchange,提问作者wonderfulworldwithcharity

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 03:27:03