Powershell 中的 Install-Module 命令是什么?

Ror*_*ory 8 powershell

微软的各种文章都提到了 Powershell 命令Install-Module,但我找不到任何关于这实际上是什么的参考,而且它不太适合谷歌搜索。我已经安装了psget,所以我有它的 Install-Module 版本……但我认为这不是其他人都在谈论的 Install-Module。

啊,我找到了这个 Install-Module。这与 PsGet 安装的不同吗?如果是这样,我应该卸载 PsGet 以便回到默认设置吗?

Ror*_*ory 18

我之前安装了PSGet,它覆盖了我的Install-Module. 您可以通过运行来检查它help install-module并查看它指的是哪个版本。

我找不到 PSGet 的卸载文档,所以我通过删除文件夹来删除它C:\Users\Rory\Documents\WindowsPowerShell\Modules\PSGet。现在help install-module指的是微软版本。


Tim*_*ell 9

您可以通过在命令前加上模块名称来解决冲突:

PsGet 安装并妨碍了:

C:\repos> install-module csproj
Module csproj was not found in central repository
At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\PsGet\PsGet.psm1:694 char:13
+             throw "Module $Module was not found in central repository ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Module csproj w...tral repository:String) [], RuntimeException
    + FullyQualifiedErrorId : Module csproj was not found in central repository
Run Code Online (Sandbox Code Playgroud)

使用限定名称:

C:\repos> powershellget\install-module csproj

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running
the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
C:\repos>
Run Code Online (Sandbox Code Playgroud)

感谢http://windowsitpro.com/blog/dealing-cmdlet-name-conflicts

通过阅读文档的 url 获得的模块名称 - https://msdn.microsoft.com/powershell/reference/5.1/PowerShellGet/install-module

更多信息:https : //andrwwatt.wordpress.com/2006/05/13/coping-with-a-powershell-naming-clash/