Closed favorini closed 7 years ago
Did you solve it?
No solution yet. Some followup over here in comments: https://blogs.msdn.microsoft.com/powershell/2016/02/24/windows-management-framework-wmf-5-0-rtm-packages-has-been-republished/#comment-128715
Try running it with the -Verbose
switch, might give you a clue
Here's what I posted in the thread I linked to. Still no resolution.
I installed .NET 4.6.1, then I installed WMF 5.0.
PS T:> dir ‘HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\’
Hive: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
Name Property —- ——– 1033 Version : 4.6.01055 TargetVersion : 4.0.0 Install : 1 Servicing : 0 Release : 394271
Here is the requested output of the commands.
PS T:> Get-Module PackageManagement,PowerShellGet -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands ———- ——- —- —————- Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa… Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module…}
PS T:> Get-PackageProvider -debug -verbose DEBUG: 00:00:00.0000003 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is “Y”): a DEBUG: 00:00:00.0000141 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsuProvider.dll DEBUG: 00:00:00.0001089 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll DEBUG: 00:00:00.0001122 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll DEBUG: 00:00:00.0026661 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsiProvider.dll DEBUG: 00:00:00.0029371 Trying provider assembly: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.202\Microsoft.PackageManagement.NuGetProvider.dll DEBUG: 00:00:00.0077523 FAILED provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsiProvider.dll DEBUG: 00:00:00.0077547 FAILED provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll DEBUG: 00:00:00.0077843 FAILED provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll DEBUG: 00:00:00.0077924 FAILED provider assembly: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.202\Microsoft.PackageManagement.NuGetProvider.dll DEBUG: 00:00:00.0078739 FAILED provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MetaProvider.PowerShell.dll DEBUG: 00:00:00.0080753 FAILED provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsuProvider.dll
@favorini, thanks for reporting it. I tried to repro it but no luck. I need your help to get some more data for the investigation. Can you do the following assuming your system dir is c:\?
dir C:\Program Files\WindowsPowerShell\Modules\PackgeManagement
dir C:\Program Files\WindowsPowerShell\Modules\PackgeManagement\1.0.0.1
dir C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PackgeManagement
get-hotfix KB3134760
Import-Module "C:\Program Files\WindowsPowerShell\Modules\PackageManagement\Microsoft.PackageManagement.CoreProviders.dll" -verbose
get-module
$a=[Microsoft.PackageManagement.Providers.Internal.Bootstrap.BootstrapProvider]::new()
$a.PackageProviderName
Clean up providers, see here for the instructions Get-PackageProvider -debug -verbose
PS T:\> dir 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\'
Directory: C:\Program Files\WindowsPowerShell\Modules\PackageManagement
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/13/2016 10:48 PM 1.0.0.1
PS T:\> dir 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\'
Directory: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/8/2016 10:01 PM en
d----- 7/13/2016 10:48 PM en-US
-a---- 7/8/2016 10:00 PM 73728 Microsoft.PackageManagement.ArchiverProviders.dll
-a---- 7/8/2016 10:00 PM 55296 Microsoft.PackageManagement.CoreProviders.dll
-a---- 7/8/2016 10:00 PM 253440 Microsoft.PackageManagement.dll
-a---- 7/8/2016 10:00 PM 68608 Microsoft.PackageManagement.MetaProvider.PowerShell.dll
-a---- 7/8/2016 10:00 PM 243712 Microsoft.PackageManagement.MsiProvider.dll
-a---- 7/8/2016 10:00 PM 14336 Microsoft.PackageManagement.MsuProvider.dll
-a---- 7/8/2016 10:00 PM 151040 Microsoft.PowerShell.PackageManagement.dll
-a---- 7/8/2016 10:00 PM 5037 PackageManagement.format.ps1xml
-a---- 7/8/2016 10:00 PM 1528 PackageManagement.psd1
-a---- 7/13/2016 10:48 PM 391 PackageManagement_4ae9fd46-338a-459c-8186-07f910774cb8_HelpInfo.xml
-a---- 7/8/2016 10:00 PM 7796 PackageProviderFunctions.psm1
PS T:\> dir C:\Windows\System32\WindowsPowerShell\v1.0\Modules\
Directory: C:\Windows\System32\WindowsPowerShell\v1.0\Modules
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---s- 5/27/2014 4:50 PM ActiveDirectory
d----- 9/2/2015 7:19 PM AdmPwd.PS
d---s- 11/21/2010 1:30 AM AppLocker
d---s- 11/21/2010 1:24 AM BitsTransfer
d----- 7/8/2016 10:01 PM CimCmdlets
d----- 5/27/2014 4:50 PM GroupPolicy
d----- 7/8/2016 10:01 PM ISE
d----- 7/13/2016 10:48 PM Microsoft.PowerShell.Archive
d----- 7/8/2016 10:01 PM Microsoft.PowerShell.Diagnostics
d----- 7/8/2016 10:01 PM Microsoft.PowerShell.Host
d----- 7/8/2016 10:01 PM Microsoft.PowerShell.Management
d----- 7/13/2016 10:48 PM Microsoft.PowerShell.ODataUtils
d----- 7/8/2016 10:01 PM Microsoft.PowerShell.Security
d----- 7/8/2016 10:01 PM Microsoft.PowerShell.Utility
d----- 7/8/2016 10:01 PM Microsoft.WSMan.Management
d----- 7/13/2016 10:48 PM NetworkSwitchManager
d----- 7/13/2016 10:48 PM PSDesiredStateConfiguration
d----- 7/8/2016 10:01 PM PSDiagnostics
d----- 7/8/2016 10:01 PM PSScheduledJob
d----- 7/8/2016 10:01 PM PSWorkflow
d----- 7/8/2016 10:01 PM PSWorkflowUtility
d----- 11/21/2010 1:24 AM TroubleshootingPack
[Note: C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PackageManagement does not exist.]
PS T:\> Get-HotFix KB3134760
Source Description HotFixID InstalledBy InstalledOn
------ ----------- -------- ----------- -----------
HITZIG Update KB3134760 DHE\xxxxxxxxxxx 7/9/2016 12:00:00 AM
PS T:\> Import-Module -Verbose "C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Mi
crosoft.PackageManagement.CoreProviders.dll"
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll'.
PS T:\> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 ActiveDirectory {Add-ADComputerServiceAccount, Add-ADDomainControllerPassw...
Binary 3.0.0.0 Microsoft.PackageManagement.Core...
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script 3.2.0.0 Pscx {Add-PathVariable, Clear-MSMQueue, Convert-Xml, ConvertFro...
Script 1.2 PSReadLine {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PS...
Script 1.0 psrr {Get-RegBinary, Get-RegDefault, Get-RegDWord, Get-RegExpan...
Script 1.2 TabExpansionPlusPlus {Get-ArgumentCompleter, Get-CommandTreeCompletion, Get-Com...
PS T:\> $a=[Microsoft.PackageManagement.Providers.Internal.Bootstrap.BootstrapProvider]::new()
PS T:\> $a.PackageProviderName
Bootstrap
PS T:\>
BTW, the ProviderAssemblies directories are empty.
PS T:\> dir $env:ProgramFiles\PackageManagement\ProviderAssemblies
PS T:\> dir $env:LOCALAPPDATA\PackageManagement\ProviderAssemblies
PS T:\> dir $env:ProgramFiles\PackageManagement
Directory: C:\Program Files\PackageManagement
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/21/2016 9:30 PM ProviderAssemblies
PS T:\> Get-PackageProvider -debug -verbose
DEBUG: 00:00:00.0000006 Trying provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
DEBUG: 00:00:00.0000117 Trying provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsiProvider.dll
DEBUG: 00:00:00.0003534 Trying provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll
DEBUG: 00:00:00.0014006 Trying provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll
DEBUG: 00:00:00.0002813 Trying provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsuProvider.dll
DEBUG: 00:00:00.1226901 FAILED provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsiProvider.dll
DEBUG: 00:00:00.1227109 FAILED provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll
DEBUG: 00:00:00.1227136 FAILED provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll
DEBUG: 00:00:00.1227333 FAILED provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsuProvider.dll
DEBUG: 00:00:00.1310014 FAILED provider assembly: C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
Hmmm. Your settings look fine to me. Let's see if FindAssembly is functioning properly on your machine. can you please try run the following?
$a=[System.IO.Path]::GetFullPath("C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll")
[System.IO.File]::Exists($a)
PS T:\> $a=[System.IO.Path]::GetFullPath("C:\Program Files\WindowsPowerShell\Modules\PackageManagement\
1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll")
PS T:\> [System.IO.File]::Exists($a)
True
PS T:\>
The issue was that I had FIPS enabled on the machine in question. Disabling FIPS solved it. MD5 hash implementation is not FIPS-Compliant. You can verify the FIPS issue as follows:
PS T:\> $a=[System.Security.Cryptography.MD5]::Create()
Exception calling "Create" with "0" argument(s): "This implementation is not part of the Windows Platform FIPS
validated cryptographic algorithms."
At line:1 char:1
+ $a=[System.Security.Cryptography.MD5]::Create()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
PS T:\> $Error[0].Exception.InnerException
This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.
With FIPS disabled it works. (Don't forget to reboot after disabling FIPS.)
PS T:\> Get-Item HKLM:\System\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy
Hive: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa
Name Property
---- --------
FipsAlgorithmPolicy Enabled : 0
PS T:\> $a=[System.Security.Cryptography.MD5]::Create()
PS T:\> Get-PackageProvider -ListAvailable
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
NuGet 2.8.5.206 Destination, ExcludeVersion, Scope, Headers, FilterOnTag, Contains, AllowP...
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, Scope, InstallUpdate, PackageManagementPr...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
PS T:\> Find-Module PSCX
Version Name Type Repository Description
------- ---- ---- ---------- -----------
3.2.2 Pscx Module PSGallery PowerShell Community Extensions (PSCX...
Thanks for coming back with a work around. Is there any chance we're going to see this work with FIPS turned on however? The organization I work wants to leverage this, but they requires FIPS to be enabled.
For this particular issue, we made the fix by changing MD5 to SHA1 which works on FIPS enabled machines. OneGet uses it to uniquely identify processed providers, not security related, so SHA1 is fine. We will keep this issue open until the binaries of OneGet are released.
Is there a fix or workaround for this short of disabling FIPS? I work in an environment were FIPS is required, and would really like to get this working. Disabling FIPS isn't an option.
@bbasselgia , the PackageManagement module we just published last week on the PowerShellGallery contains the fix. You may follow our blog to try it out. thx
This is getting a bit frustrating. for something that is suppose to make life easier, this shouldn't be that hard. If this actually worked it would be great. But, there are a lot of us who work in disconnected environments, not having a stand alone installer for this stuff is leaving us high and dry.
I'm still not able to get any of the package managment commands to work. Here is my environemnt: PS U:> [System.Environment]::osversion
Platform ServicePack Version VersionString
Win32NT Service Pack 1 6.1.7601.65536 Microsoft Windows NT 6.1.7601 Service Pack 1
PS U:> $PSVersionTable
Name Value
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
FIPS is enabled and cannot be disabled, even temporarily. I'm behind a proxy server that requires authentication.
When I try to install any module with the install-module command, it tells me in needs NuGet. I tell it yes to install NeGet and it fails with:
Unable to find repository with SourceLocation ''.
get-packageprovider -listavailable returns nothing.
get-psrepository fails with:
Unable to find module providers (powershellget).
I have no doubt that the security settings on my system (such as the FIPS requirement) are causing the problems.
Any help getting this working would be greatly appreciated.
I am currently tied up with other work. I look into it after a week or so. Sorry for the inconvenience.
@jianyunt , you are correct, disabling FIPS allows this to function. However, the PackageManagement module you mention above does not resolve the issue when FIPS is enabled. The updated module throws the following error when fips is enabled:
`PackageManagement\Install-Package : Package 'xWebAdministration' failed to be installed because: Exception has been thrown by the target of an invocation. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.0.0\PSModule.psm1:1800 char:21
- CategoryInfo : InvalidResult: (xWebAdministration:String) [Install-Package], Exception
- FullyQualifiedErrorId : Package '{0}' failed to be installed because: {1},Microsoft.PowerShell.PackageManagement
.Cmdlets.InstallPackage`
That being said, I am able to use local repositories. The workaround I am using is to temporarily disable fips (adjust the registry key), save the module to my local repository, and re-enable fips. It works, but it would be fantastic if this were fips-compliant.
@bbasselgia, @mtrog thanks for you info. I tried on my Win10 box, I was not able to repro it. However I am able to repro it on Windows Server 2012 R2 VM. When a user types install-module, OneGet and NuGet provider parse the package metadata where we find the package hash algorithm. Then we uses this hash algorithm to validate if the downloaded package is valid.
On FIPS enable machine, I saw the exception as you mentioned above. See details below. Do you know HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy\Enabled is always 1 on FIPS enabled machines?
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.
at System.Security.Cryptography.SHA512Managed..ctor()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Security.Cryptography.CryptoConfig.CreateFromName(String name, Object[] args)
at System.Security.Cryptography.SHA512.Create()
at Microsoft.PackageManagement.NuGetProvider.NuGetClient.InstallPackage(String packageName, String version, NuGetRequest request, PackageSource source,
String queryUrl, String packageHash, String packageHashAlgorithm, ProgressTracker progressTracker)
Yes. My workaround is to use set-itemproperty to change the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy\Enabled to 0 and relaunch powershell. I then install the module and publish it to my local repository. After this, I use gpupdate or set-item property to set the value of enabled back to 1 (GPO is configured to enforce this).
On Wed, Oct 19, 2016, 12:18 PM Jianyun notifications@github.com wrote:
@bbasselgia https://github.com/bbasselgia, @mtrog https://github.com/mtrog thanks for you info. I tried on my Win10 box, I was not able to repro it. However I am able to repro it on Windows Server 2012 R2 VM. When a user types install-module, OneGet and NuGet provider parse the package metadata where we find the package hash algorithm. Then we uses this hash algorithm to validate if the download package is valid.
On FIPS enable machine, I saw the exception as you mentioned above. See details below. Do you know HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy\Enabled is always 1 on FIPS enabled machines?
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms. at System.Security.Cryptography.SHA512Managed..ctor() --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Security.Cryptography.CryptoConfig.CreateFromName(String name, Object[] args) at System.Security.Cryptography.SHA512.Create() at Microsoft.PackageManagement.NuGetProvider.NuGetClient.InstallPackage(String packageName, String version, NuGetRequest request, PackageSource source, String queryUrl, String packageHash, String packageHashAlgorithm, ProgressTracker progressTracker)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OneGet/oneget/issues/195#issuecomment-254913377, or mute the thread https://github.com/notifications/unsubscribe-auth/AV4GdEMwWR4RW4Ezr71fugXUupgQhKmEks5q1m0JgaJpZM4JJtM7 .
@mtrog, @bbasselgia, may I ask you favor? I made code change for fixing this issue and the build is out, see here. You need to download the zip, unzip it, and copy the entire folder to your target machine under "$env:ProgramFiles\WindowsPowerShell\Modules\PackageManagement\1.1.0.0"
Because the binaries are not signed. You need to run ignore strong name verification. See how our test does it.
After that, relaunch PowerShell console. Please let me know it it works for you. Thanks again!
I've hit the same issue with FIPS compliance enabled. I'll test this tomorrow too....
@pburkholder thank you. Please make sure the NuGetProvider is loaded from the package. You can delete the Nuget provider from $env:ProgramFiles\PackageManagement\ProviderAssemblies\nuget first before launching the PowerShell Console. Get-PackageProvider -name NuGet | fl to check if it is loaded from the OneGet folder.
Hi - This looks good. I unzipped your package as directed, and ran the registry updates per https://gist.github.com/pburkholder/2ff8afd73043e836ddcbfa9d158ae21c. Then started a new Admin powershell:
Windows PowerShell
Copyright (C) 2015 Microsoft Corporation. All rights reserved.
PS C:\windows\system32> Get-PackageProvider
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
NuGet 2.8.5.207 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, Scope, InstallUpdate, Filter, Tag, Includ...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
PS C:\windows\system32> Get-Item HKLM:\System\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy
Hive: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa
Name Property
---- --------
FipsAlgorithmPolicy Enabled : 1
PS C:\windows\system32>
I unzipped the package, moved the files, and disabled strong name validation per your instructions. I am now unable to import the packagemanagement module. See below:
`Windows PowerShell Copyright (C) 2015 Microsoft Corporation. All rights reserved.
PS C:\WINDOWS\system32> import-module PackageManagement Import-Module : Could not load file or assembly 'file:///C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.1.0.0\fullclr\Microsoft.PackageManagement.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) At C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.1.0.0\PackageManagement.psm1:34 char:17
- CategoryInfo : NotSpecified: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand`
I did not reboot the server to test this, but I did relaunch powershell as an administrator.
Thank you @pburkholder for the validation.
@mtrog, is it possible your machine is somehow blocking the files from getting dll loaded. Can you please try: right click on one dll file -> Properties->General
If you see "This file came from another computer and might be blocked to help protect this computer" under Security, click on unblock check box.
My apologies, an oversight on my part. You were correct, the files were blocked. That being said... The behavior with FIPS enabled, the provided patch applied, and strong names disabled:
PS C:\WINDOWS\system32> install-Module xSQLServer
PackageManagement\Install-Package : Package 'xSQLServer' failed to be installed because: Exception has been thrown by
the target of an invocation.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.0.0\PSModule.psm1:1800 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (xSQLServer:String) [Install-Package], Exception
+ FullyQualifiedErrorId : Package '{0}' failed to be installed because: {1},Microsoft.PowerShell.PackageManagement
.Cmdlets.InstallPackage
The behavior with FIPS disabled:
PS C:\WINDOWS\system32> Install-Module xSQLServer
PS C:\WINDOWS\system32>
@mtrog, can you please make sure you remove the existing nuget provider first and then launch the PowerShell console. thx again for trying it. $env:ProgramFiles\PackageManagement\ProviderAssemblies\nuget $env:LOCALAPPDATA\PackageManagement\ProviderAssemblies
it works now, thanks!
PS C:\WINDOWS\system32> Get-PackageProvider -name nuget| Select-Object name, providerpath
Name ProviderPath
---- ------------
NuGet C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.1.0.0\fullclr\Microsoft.PackageManagement.NuGet...
PS C:\WINDOWS\system32> Get-Item HKLM:\system\CurrentControlSet\Control\lsa\FipsAlgorithmPolicy
Hive: HKEY_LOCAL_MACHINE\system\CurrentControlSet\Control\lsa
Name Property
---- --------
FipsAlgorithmPolicy Enabled : 1
PS C:\WINDOWS\system32> install-module xSCOM
PS C:\WINDOWS\system32>
Great. Thank you! The change will be published to PowerShellGallery.com soon.
I had the same issue with PackageManagement\Install-Package : Package 'xSQLServer' failed to be installed because: Exception has been thrown by the target of an invocation.
but it was resolved by, indeed, removing the NuGet provider.
I could NOT remove the nuget provider from within powershell The action can't be completed because the file is open in powershell.exe
so I had to use explorer.
@jianyunt Look forward to the upcoming release. Can you update this issue when that happens? Thanks, Peter
Just published the PackageManagement module to PowerShellGallery.com.
You can run install-module PowerShellGet -force
to get the latest PowerShellGet, NuGet Provider and PackageManagement modules.
Because PowerShellGet depends on PackageManagement, 'install-module PowerShellGet -force' will auto install PackageManagement. The new version is 1.1.1.0.
Problem:
Install-Module
to upgrade because of 1.Solution:
nuget.exe
iwr https://www.powershellgallery.com/api/v2/package/PackageManagement/1.1.1.0 -Outfile .\packagemanagement.1.1.1.0.nupkg
iwr https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -Outfile .\nuget.exe
$module_dir="$HOME\Documents\WindowsPowerShell\Modules\"
./nuget.exe install PackageManagement -Source $pwd `
-OutputDirectory $module_dir `
-Verbosity detailed
Rename-Item $module_dir/PackageManagement.1.1.1.0 $module_dir/PackageManagement
Open a new powershell and test with
Install-Module -Scope CurrentUser PSScriptAnalyzer
Hi, I'm having a problem very similar to the OP, except that I don't have FIPS policies enabled. I've already double-checked connectivity, and I can watch PowerShell attempting to reach 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' via packet capture. I don't have a MitM proxy enabled, so I can't be certain what's going on in the session, but I can see the TLS handshake with the server.
I used the example in your last post to update both PackageManagement and PowerShellGet to their latest versions (1.1.4.0 and 1.1.3.1, respectively) installed in the local user account's PowerShell modules directory, and verified the working versions with Get-Module.
LOCALHOST user C:/Users/user/Downloads # Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.0 chocolateyProfile {TabExpansion, Update-SessionEnvironment, refreshenv}
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...}
Script 1.1.4.0 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script 1.1.3.1 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script 1.0.0.13 PSReadline {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandler, Set-PSReadlineKeyHandler...}
Every time I try anything similar to 'Install-Module -Scope CurrentUser PSScriptAnalyzer', I get kicked back to the requirement for the NuGet provider, which always fails to install.
I've also performed all the above tests, which function correctly. The only other difference from the above is that I believe I went directly from PowerShell 4.x to 5.1.
I have no proxy, and I disabled all forms of adblocking (DNS included) while testing. There is nothing installed that should be interrupting or mangling outside connectivity. Obviously, I can download the URI PowerShell is trying for by using a browser--any browser. Again, I have no proxy. (I control all aspects of the local network.)
LOCALHOST user C:/Users/user/Downloads # Update-Module -verbose PSReadline
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\user\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider byrunning 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to installand import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
VERBOSE: Installing NuGet provider.
VERBOSE: Using the provider 'Bootstrap' for searching packages.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'NuGet','','2.8.5.201','''.
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more times.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.
At C:\Users\user\Documents\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:7512 char:21
+ ... $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac
kageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro
vider
PackageManagement\Import-PackageProvider : No match was found for the specified search criteria and provider name 'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
At C:\Users\user\Documents\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:7518 char:21
+ ... $null = PackageManagement\Import-PackageProvider -Name $script:Nu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (NuGet:String) [Import-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProv
ider
VERBOSE: No match was found for the specified search criteria and provider name 'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'NuGet','','0.0.0.1','''.
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more times.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Get-PackageProvider : Unable to find package provider 'NuGet'. It may not be imported yet. Try 'Get-PackageProvider -ListAvailable'.
At C:\Users\user\Documents\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:7522 char:30
+ ... tProvider = PackageManagement\Get-PackageProvider -Name $script:NuGet ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvi
der], Exception
+ FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPacka
geProvider
Update-Module : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed.
At line:1 char:1
+ Update-Module -verbose PSReadline
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Update-Module], InvalidOperationException
+ FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Update-Module
LOCALHOST user C:/Users/user/Downloads #
Does PackageManagement 1.1.3.0 work for you? We are seeing https://github.com/OneGet/oneget/issues/289 issue on download level WS2012 R2 machine. What's your os?
@jianyunt I provided that information. My situation is nearly identical to the OP, who is running 7 SP1 x64. I'm also running 7 SP1 x64. The only significant difference is that I do not have FIPS policies enabled. My ProviderAssemblies folders are empty, like the OP's and so forth.
I cannot install or upgrade any packages, as I explained in my comment.
re-launch powershell Get-module PackageManagement -list if you have PackageManagement version 1.1.3.0 available Import-Module PackageManagement -RequiredVersion 1.1.3.0 -force Get-module PackageManagement
now find-module xjea for example
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
LOCALHOST user C:/Windows/system32 # Get-module PackageManagement -list
Directory: C:\Program Files (x86)\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Directory: C:\Users\user\Documents\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.1.4.0 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
LOCALHOST user C:/Windows/system32 # Import-Module PackageManagement -RequiredVersion 1.1.3.0 -force
Import-Module : The specified module 'PackageManagement' with version '1.1.3.0' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ Import-Module PackageManagement -RequiredVersion 1.1.3.0 -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (PackageManagement:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleWithVersionNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
LOCALHOST user C:/Windows/system32 # Import-Module PackageManagement -RequiredVersion 1.1.4.0 -force
LOCALHOST user C:/Windows/system32 # Get-module PackageManagement
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.1.4.0 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
LOCALHOST user C:/Windows/system32 # find-module xjea
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'xjea'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1360 char:3
+ PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage
LOCALHOST user C:/Windows/system32 # Get-PSRepository
WARNING: Unable to find module repositories.
LOCALHOST user C:/Windows/system32 #
go ahead rename or delete 1.1.4.0 folder under PackageManagement . relaunch powershell Import-Module PackageManagement -RequiredVersion 1.1.3.0 -force
I don't think you understand. I can't install any packages at all that require any kind of download from microsoft.com.
See again:
VERBOSE: No match was found for the specified search criteria and provider name 'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'NuGet','','0.0.0.1','''.
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more times.
WARNING: Unable to download the list of available providers. Check your internet connection.
I suspect it's caused by the new version of PackageManagement, 1.1.4.0. That's why I am asking you to delete 1.1.4.0 and try find-module or package again.
Yes, I understand. I tested with the version shipped with PowerShell (WMF 5.1 for 7 SP1 x64) and with 1.1.3.0 before I realized that 1.1.4.0 was available.
The results are the same in all three cases: I can't download anything, and I can't install a package unless I go to the trouble of downloading every component by hand. Whichever package manager is in control, it always demands that NuGet be installed, then fails to install it.
I've seen this exact problem (7 SP1, WMF 5.1, NuGet download failure even though Internet connectivity without a proxy is present) reported on several Microsoft forums, but with no resolution.
Is there any way to get more logging from whatever components are providing the actual download capability? The fact that OneGet can contact Microsoft (Akamai) servers, but refuses to download and install packages, makes me wonder if it's a different problem in SChannel, or somewhere else in the stack.
@rmenessec Did you manually copy 1.1.4.0 version on your machine considering you cannot download any modules? @JKeithB, can we setup a live meeting with rmenessec for better understanding his case? thx
@rmenessec - if you would be willing to work with us directly on this, please send email to keithb at microsoft dot com (trying to avoid gh trolls), and we can set up a time where we can work with you directly.
@rmenessec Some questions:
-Debug
to the Update-Module
command? Probably won't help too much, but it's still additional info.webClient.DownloadFileCompleted += (sender, args) => {
if (args.Cancelled || args.Error != null) {
localFilename = null;
}
done.Set();
}
...since the message has an empty localFileName
argument. As you can see, the request and the error aren't logged. I'll try to get a commit in tomorrow to add the proper logging here. May not get in tomorrow. Would you be willing to try to capture the request to see if you can grab the error directly? If not, would you be willing to try to re-run Update-Module
with the error messages enabled?
@brywang-msft,
1: Sure!
2: Sure!
Can you provide the full command line you'd like to see invoked? Just 'Update-Module -Debug', or are there other options or conditions that you're looking for?
I see that it produces a huge amount of output; what's the easiest way to log this? And can I log it without having to run it interactively?
3: When you say 'capture', do you mean console output, packets, or both? I can't do the packet capture side immediately, but otherwise yes. Or—if you're looking for the contents of a TLS session, probably not; not unless you have a way to downgrade the connection to HTTP. Otherwise, I'd have to set up something like mitmproxy, which isn't entirely trivial.
Side note: I'm getting ready to upgrade the victim machine from 7SP1 to 10 with a clean reinstall; hopefully in the next two weeks. Since I'm 99.9% sure this isn't related to my network environment or anything hiding in the related infrastructure (DNS and so forth), chances are pretty good this will wipe out... whatever's causing PowerShell's network operations to fail selectively.
Since I plan to reinstall my handful of PowerShell modules, though, it seems possible that there's something in there that kicked off this whole mess...
It seems like the original issue w.r.t WMF 4 to WMF5 is resolved. Hence closing this one.
I am still not able to install modules when in FIPS mode. Is there any intent on correcting this?
Upgraded from WMF 4.0 to WMF 5.0 on Windows 7 SP1 x64 with .NET 4.6.1 and can't get NuGet/OneGet etc. to work at all. Already tried uninstall of WMF 5.0 and reinstall to no avail. Also tried Set-ExecutionPolicy Bypass--same error.