安装PowerShellGet模块

安装PowerShellGet模块

问题描述:

请有人可以帮助我与Powershell。我是新手,有点迷路。安装PowerShellGet模块

我正在使用Windows 2012 R2,它运行的是Powershell版本4.0。我已升级到5.0版。

看来,当我做基本的命令,我得到的错误,例如

PS C:\Windows\system32> Install-Module –Name PowerShellGet –Force –Verbose 

安装-模块:“安装-模块”命令模块 “PowerShellGet”中发现,但模块不能被加载。有关更多 信息,请运行“Import-Module PowerShellGet”。在线:1 char:1 + Install-Module -Name PowerShellGet -Force -Verbose + ~~~~~~~~~~~~~~~~~~安装模块:字符串[] ,CommandNotFoundException + FullyQualifiedErrorId:CouldNotAutoloadMatchingModule

又如:

PS C:\Windows\system32> import-module PowerShellGet 

获取变量:术语 '获取变量' 不被识别为名称的cmdlet的 ,函数,脚本文件或可操作程序。检查名称的拼写,或者如果包含路径,请确认路径 是正确的,然后重试。在C:\ Program Files \ WindowsPowerShell \ Modules \ PowerShellGet \ 1.1.3.2 \ PSModule.psm1:18 char:28 + $ script:IsWindows =(-not(Get-Variable -Name IsWindows -ErrorAction ... + ~~~~~~~~~~~~ + CategoryInfo:ObjectNotFound:(获取变量:字符串)[],CommandNotFoundException + FullyQualifiedErrorId:CommandNotFoundException

我基本上按照对PowerShellGet安装方法这里找到:https://docs.microsoft.com/en-us/powershell/gallery/psget/get_psget_module

我卡在本指南中的“安装 - 模块”命令

+0

杰夫嗨,欢迎SO!请花点时间仔细研究以改进您的问题和格式:https://*.com/help/how-to-ask – petezurich

如果你已经升级到WMF 5.0,你有PowerShellGet。兼营:

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted 

这时你可以用查找模块和安装的模块来获得你所需要的。

感谢@JohnDonnelly的答复。

当我运行该命令我得到:

集-PSRepository:在“设置PSRepository”命令的 模块 “PowerShellGet”中发现的,但模块不能 加载。有关更多信息,请运行“Import-Module PowerShellGet”。 At line:1 char:1 + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + ~~~~~~~~~~~~~~~~~~~~~~~~~~(Set-PSRepository:String) [],CommandNotFoundException + FullyQualifiedErrorId:CouldNotAutoloadMatchingModule

+0

当您键入Get-Module时,您是否在列表中看到PowerShellGet?还输入$ PSVersionTable并确保PSVersion是5 –

这是我得到执行上面的命令时:@johndonnelly

PS C:\Windows\system32> Get-Module 

ModuleType版本名称ExportedCommands ---------- ------- ---- ---------------

脚本1.1.6.0 PackageManagement
脚本1.2 PSReadline {GET-PSReadlineKeyHandler, GET-PSReadlineOption,删除-PS ...

PS C:\Windows\system32> $PSVersionTable 

名称值 ---- -----
PSVersion 5.0.10586.117
PSCompatibleVersions { 1.0,2.0,3.0,4.0 ...}
BuildVersion 10.0.10586.117
CLRVERSION 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

+0

嗨,伙计们。任何帮助将不胜感激。请。谢谢 –