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

profile.ps1中Import-Module无法加载模块?问题排查与解决方法

PowerShell配置文件自动加载模块失败,手动执行正常的解决办法

问题详情

  • 配置文件位置:Documents/WindowsPowerShell/profile.ps1,启动pwsh时自动执行
  • 故障现象:配置文件中的Import-Module -Global ./Modules/test/test.psm1无法加载模块,但手动在Shell中执行相同命令(或完整路径命令Import-Module .\OneDrive\Documents\WindowsPowerShell\Modules\DisplaySettings/DisplaySettings.psm1)可正常加载
  • 模块类型:基于.NET 7.0的C#模块

解决步骤

  1. 执行命令查看所有PowerShell配置文件的完整路径:
$Profile|Format-List * -Force
  1. 将目标模块移动到CurrentUserAllHosts对应路径下的Modules文件夹中,配置文件即可自动加载该模块。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 04:30:54