【发布时间】:2020-07-19 14:21:00
【问题描述】:
关于模块,Doc 提到了它的可取性
使用 .psm1 扩展名保存 PowerShell 脚本。对脚本和保存脚本的目录使用相同的名称。
要安装和运行您的模块,请将模块保存到适当的 PowerShell 路径之一,然后使用 Import-Module。
PowerShell 路径 -> 位于$env:PSModulePath
我没有关注它们并将脚本模块chart_gui.psm1 保存在本地文件夹之一中,我仍然可以Import-Module 并在其中调用函数,但Remove-Module 抛出错误。
Import-Module 'H:\path_x\chart_gui.psm1'
#Call the function
$selectedCharts = selectCharts
Remove-Module 'H:\path_x\chart_gui.psm1'
我的错误:
Remove-Module : No modules were removed. Verify that the specification of modules to remove is correct and those modules exist in the runspace.
我的$env:PSModulePath
PS C:\Users\xxx> $env:PSModulePath
C:\Users\xxx\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\Windo
wsPowerShell\v1.0\Modules
【问题讨论】:
标签: powershell