我的组织中有一个开发人员无法从我们内部的NuGet存储库安装Powershell模块。他具有与我相同的PowershellGet版本,但是我没有这样的问题。
他的机器
PS C:\> install-module xyz.ps.core -Scope CurrentUser -Force -Verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'http://devstatic.xyz.com/prdnuget/nuget' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'http://devstatic.xyz.com/prdnuget/nuget/FindPackagesById()?id='xyz.ps.core'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'xyz.ps.core'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='xyz.ps.core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'xyz.ps.core'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.0.19206.6' of module 'xyz.PS.Core'".
VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in 'C:\Users\P124629\OneDrive - Ceridian HCM Inc\Documents\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'xyz.PS.Core' with version '1.0.19206.6' from the repository 'http://devstatic.xyz.com/prdnuget/nuget'.
VERBOSE: Searching repository 'http://devstatic.xyz.com/prdnuget/nuget/FindPackagesById()?id='xyz.PS.Core'' for ''.
VERBOSE: InstallPackage' - name='xyz.PS.Core', version='1.0.19206.6',destination='C:\Users\P124629\AppData\Local\Temp\1104224955'
VERBOSE: DownloadPackage' - name='xyz.PS.Core',
version='1.0.19206.6',destination='C:\Users\P124629\AppData\Local\Temp\1104224955\xyz.PS.Core\xyz.PS.Core.nupkg',
uri='http://devstatic.xyz.com/prdnuget/nuget/'
VERBOSE: Downloading 'http://devstatic.xyz.com/prdnuget/nuget/package/xyz.PS.Core/1.0.19206.6'.
WARNING: Could not get response from query 'http://devstatic.xyz.com/prdnuget/nuget/package/xyz.PS.Core/1.0.19206.6'.
VERBOSE: Downloading package 'xyz.PS.Core' failed, please make sure 'http://devstatic.xyz.com/prdnuget/nuget/package/xyz.PS.Core/1.0.19206.6' is
accessable.
WARNING: MSG:SourceLocationNotValid «http://devstatic.xyz.com/prdnuget/nuget/»
PackageManagement\Install-Package : Package 'xyz.PS.Core' failed to install.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (C:\Users\P12462...e.PS.Core.nupkg:String) [Install-Package], Exception
+ FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
PS C:\>
注意以下行:
VERBOSE: DownloadPackage' - name='xyz.PS.Core',
version='1.0.19206.6',destination='C:\Users\P124629\AppData\Local\Temp\1104224955\xyz.PS.Core\xyz.PS.Core.nupkg',
uri='http://devstatic.xyz.com/prdnuget/nuget/'
我的机器
C:\> Install-Module xyz.PS.Core -Scope CurrentUser -Force -Verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'http://devstatic.xyz.com/prdnuget/nuget' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'http://devstatic.xyz.com/prdnuget/nuget/FindPackagesById()?id='xyz.PS.Core'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'xyz.PS.Core'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='xyz.PS.Core'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'xyz.PS.Core'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.0.19206.6' of module 'xyz.PS.Core'".
VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in 'C:\Users\me\Documents\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'xyz.PS.Core' with version '1.0.19206.6' from the repository
'http://devstatic.xyz.com/prdnuget/nuget'.
VERBOSE: Searching repository 'http://devstatic.xyz.com/prdnuget/nuget/FindPackagesById()?id='xyz.PS.Core'' for ''.
VERBOSE: InstallPackage' - name='xyz.PS.Core',
version='1.0.19206.6',destination='C:\Users\me\AppData\Local\Temp\1058687073'
VERBOSE: DownloadPackage' - name='xyz.PS.Core',
version='1.0.19206.6',destination='C:\Users\me\AppData\Local\Temp\1058687073\xyz.PS.Core\xyz.PS.Core.nupkg',
uri='http://devstatic.xyz.com/prdnuget/nuget/Packages(Id='xyz.PS.Core',Version='1.0.19206.6')/Download'
VERBOSE: Downloading 'http://devstatic.xyz.com/prdnuget/nuget/Packages(Id='xyz.PS.Core',Version='1.0.19206.6')/Download'.
VERBOSE: Completed downloading
'http://devstatic.xyz.com/prdnuget/nuget/Packages(Id='xyz.PS.Core',Version='1.0.19206.6')/Download'.
VERBOSE: Completed downloading 'xyz.PS.Core'.
VERBOSE: Hash for package 'xyz.PS.Core' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='xyz.PS.Core',
version='1.0.19206.6',destination='C:\Users\me\AppData\Local\Temp\1058687073'
VERBOSE: Catalog file 'xyz.PS.Core.cat' is not found in the contents of the module 'xyz.PS.Core' being installed.
VERBOSE: For publisher validation, current module 'xyz.PS.Core' with version '1.0.19206.6' with publisher name ''. Is this module
signed by Microsoft: 'False'.
VERBOSE: For publisher validation, using the previously-installed module 'xyz.PS.Core' with version '1.0.19206.6' under
'C:\Users\me\Documents\WindowsPowerShell\Modules\xyz.PS.Core\1.0.19206.6' with publisher name ''. Is this module signed by
Microsoft: 'False'.
VERBOSE: Module 'xyz.PS.Core' was installed successfully to path
'C:\Users\me\Documents\WindowsPowerShell\Modules\xyz.PS.Core\1.0.19206.6'.
C:\>
注意以下行:
VERBOSE: DownloadPackage' - name='xyz.PS.Core',
version='1.0.19206.6',destination='C:\Users\me\AppData\Local\Temp\1058687073\xyz.PS.Core\xyz.PS.Core.nupkg',
uri='http://devstatic.xyz.com/prdnuget/nuget/Packages(Id='xyz.PS.Core',Version='1.0.19206.6')/Download'
区别在于DownloadPackage阶段报告的uri:
我不知道如何解决此问题。他安装了与我相同的PS模块。
有什么办法解决此问题吗?
(我们在Windows 10上使用Powershell 5.1)
编辑1
他的机器
PS C:\> Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
nuget.org NuGet False https://api.nuget.org/v3/index.json
xyz PowerShellGet True http://devstatic.xyz.com/prdnuget/nuget
PSGallery PowerShellGet True https://www.powershellgallery.com/api/v2
PS C:\> dir $env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet
Directory: C:\Users\P124629\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 7/25/2019 1:31 PM 5674 PSRepositories.xml
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.592
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.592
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-W...
Binary 1.0.0.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackagePro...
Script 1.0.0.1 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCapabilit...
Script 2.0.0 PSReadline {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLi...
PS C:\>
我的机器
C:\> Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
Microsoft Visual Studio Offli... NuGet False C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
NuGet.org NuGet False https://api.nuget.org/v3/index.json
xyz PowerShellGet True http://devstatic.xyz.com/prdnuget/nuget
PSGallery PowerShellGet True https://www.powershellgallery.com/api/v2
C:\> dir $env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet
Directory: C:\Users\me\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 4/12/2019 8:04 PM 1686528 NuGet.exe
-a---- 7/26/2019 12:06 PM 5328 PSRepositories.xml
C:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.592
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.592
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
C:\> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.192... xyz.PS.Core {Add-ComputedFieldsToBuild, Add-xyzDatabaseIfNotFound, Assert-Elevated,...
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Binary 1.0.0.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script 1.0.0.1 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script 2.0.0 PSReadline {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler...
C:\>
差异:
PS
开头。不知道是否相关。$env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet
中有nuget.exe,他没有。Microsoft.PowerShell.Security
和Microsoft.WSMan.Management
。不知道这是否相关。运行procmon.exe并过滤到nuget.exe并不表明Install-Module
完全在我的计算机上运行它。好像它通过nuget客户端dll进入NuGet逻辑。为了证明我的观点,我在机器上重命名了该文件,而Install-Module
仍然可以正常工作。
答案 0 :(得分:0)
我遇到了同样的问题,一个盒子上的模块路径不同于另一个盒子。我要解决的问题是将nuget程序集从C:\Program Files\PackageManagement\ProviderAssemblies\nuget
从我的盒子复制到另一个盒子。这解决了问题。我的盒子有一个较新的版本。