导入模块 posh-docker 不工作

Import-Module posh-docker is not working

Import-Module posh-docker 未使用 Power Shell 而 运行 作为管理员

我正在尝试为当前电源启用自动完成命令Shell,但出现以下错误。 executionpolicy 已设置为 RemoteSigned。我的系统中有 Docker 工具箱。

Import-Module : The specified module 'posh-docker' was not loaded because no valid module 
 file was found directory. At line:1 char:1
+ Import-Module posh-docker
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (posh-docker:String) [Import-Module], FileNotFoundExc
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

从你的问题来看,你似乎在关注 the instructions on this page,内容如下:

you can install the posh-docker PowerShell Module as follows:

(强调我的)。他们的措辞不正确;这些步骤用于在模块安装后导入模块。

安装 模块的说明在 the GitHub page for posh-docker 上。您必须首先遵循这些说明:

Windows 10 / Windows Server 2016

  1. Open a powershell prompt
  2. Run Install-Module -Scope CurrentUser posh-docker

Earlier Windows versions

  1. Install PackageManagement PowerShell Modules Preview
  2. Open a powershell prompt
  3. Run Install-Module -Scope CurrentUser posh-docker

如果您使用的是较早的 Windows 版本,我会推荐一件事:不要单独安装 PackageManagement,只需安装 Windows Management Framework 5.0 即可获得所有 PowerShell 5。

在撰写本文时,它是最新的稳定版,但下个月(2017 年 1 月)WMF 5.1 应该发布,仅供参考。

已接受的答案对我不起作用。

  1. 删除%userprofile%\Documents\WindowsPowerShell\modules\posh-docker\*
  2. 运行 Install-Module -Scope AllUsers posh-docker 来自管理 powershell