PowerShell / PackageManagementProviderResource

Modules with DSC resources for the PackageManagement(aka OneGet) providers.
MIT License
37 stars 24 forks source link

Issues configuring PSGallery package Source #27

Closed gaelcolas closed 8 years ago

gaelcolas commented 8 years ago

Hi, I've tried v1.0.3 and thanks for the improvements. I have the following issue when trying to configure PSGallery Repo to trusted:

PackageManagementSource PSGallery #This fails
        {
            Ensure      = 'Present'
            Name        = 'PSGallery'
            ProviderName= 'PowerShellGet'
            SourceUri   = 'https://www.powershellgallery.com/api/v2/'  
            InstallationPolicy ='Trusted'
        }

I get the following: image

However configuring, say, Chocolatey works:

PackageManagementSource Chocolatey
        {
            Ensure      = 'Present'
            Name        = 'Chocolatey'
            ProviderName= 'Chocolatey'
            SourceUri   = 'http://chocolatey.org/api/v2/'  
            InstallationPolicy ='Trusted'
        }
gaelcolas commented 8 years ago

I forgot to say that's not a blocker because I can still install package/PSModule via setting the InstallationPolicy to trusted without changing the PackageSource config.

Krishna-Vutukuri commented 8 years ago

@gaelcolas Thanks for reporting this issue. I will look into this.

Krishna-Vutukuri commented 8 years ago

@gaelcolas May I know the build number of the Windows you are running this on. The example at https://github.com/PowerShell/PackageManagementProviderResource/blob/master/Examples/Sample_Install_Package.ps1 is working fine on my machine.

gaelcolas commented 8 years ago

@KrishnaV-MSFT I was using an updated version of win 2012 r2 Eval. Will give you build number and details to reproduce in the next couple of days. Thanks.

gaelcolas commented 8 years ago

Hi @KrishnaV-MSFT, I'm testing this on a Win2012 R2 recently patched with WMF5 RTM Installed.

PS C:\Users\Administrator> $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.34209
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:\Users\Administrator> gwmi win32_operatingsystem

SystemDirectory : C:\Windows\system32
Organization    :
BuildNumber     : 9600
RegisteredUser  : Windows User
SerialNumber    : 00252-90000-00000-AA632
Version         : 6.3.9600

Here's the output I get:

VERBOSE: [WIN-6DJ0UDMP803]: LCM:  [ Start  Set      ]  [[PackageManagementSource]PSGallery]
WARNING: [WIN-6DJ0UDMP803]:                            [[PackageManagementSource]PSGallery] Begin registering
'PSGallery' to source location 'https://www.powershellgallery.com/api/v2/' with 'Trusted' policy"
VERBOSE: [WIN-6DJ0UDMP803]:                            [[PackageManagementSource]PSGallery] Begin invoking
Register-Packagesource PSGallery
VERBOSE: [WIN-6DJ0UDMP803]:                            [[PackageManagementSource]PSGallery] Repository
details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2/'; IsTrusted = 'False';
IsRegistered = 'True'.
WARNING: [WIN-6DJ0UDMP803]:                            [[PackageManagementSource]PSGallery] The specified
repository 'PSGallery' cannot be unregistered.
Cannot bind argument to parameter 'Location' because it is an empty string.
    + CategoryInfo          : InvalidData: (Microsoft.Power...erPackageSource:) [], CimException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Resolve-Location,Microsoft.PowerSh
   ell.PackageManagement.Cmdlets.RegisterPackageSource
    + PSComputerName        : localhost

VERBOSE: [WIN-6DJ0UDMP803]: LCM:  [ End    Set      ]  [[PackageManagementSource]PSGallery]  in 2.2650
seconds.
PowerShell DSC resource MSFT_PackageManagementSource  failed to execute Set-TargetResource functionality with error
message: Failed to register the package source PSGallery. Message:System.Exception: Cannot bind argument to parameter
'Location' because it is an empty string.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost

VERBOSE: [WIN-6DJ0UDMP803]:                            [] Consistency check completed.
The SendConfigurationApply function did not succeed. LCM failed to start desired state configuration manually.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : localhost

VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 10.156 seconds
PS C:\Users\Administrator>

I've put my test together here: https://github.com/gaelcolas/PMPR_issue27

Let me know if any question.

Gael

jianyunt commented 8 years ago

Hi @gaelcolas, we cannot register or unregister the PSGallery package source on WMF 5.0 RTM. However in TP5 or later, we added a support to allow registering/unregistering the PSGallery. As you are running on the Down-Level OS that you can not use TP5, I can add a workaround in this DSC resource for your scenario. Stay tuned.

jianyunt commented 8 years ago

@gaelcolas, I made a change to MSFT_PackageManagementSource.psm1. Can you please try it and let me know if it works for you. If so I will update this module in PowerShellGallery.com. Thanks.

gaelcolas commented 8 years ago

Sorry for the delay in testing this, this is now working. Many thanks :)