Install-PackageProvider installs but gives warning when trying to import
PS C:\> Find-PackageProvider gitlabprovider | Install-PackageProvider
Name Version Source Summary
---- ------- ------ -------
GitLabProvider 1.3.8 PSGallery GitLab PackageManagement provider
WARNING: Import-PackageProvider failed. Possibly the provider name is different from the package name ''. Try Get-PackageProvider -ListAvailable to identify the associated provider name and run Import-PackageProvider".
However, if I manually try the Import-PackageProvider after, it appears to work:
PS C:\> Import-PackageProvider GitLab -Verbose -Debug
DEBUG: 00:00:00.0000003 Calling ImportPackageProvider. providerName = 'GitLab', requiredVersion='', minimumVersion = '', maximumVersion=''
DEBUG: 00:00:00.0000498 Calling ImportPackageProviderViaName. providerName = 'GitLab', requiredVersion='', minimumVersion = '', maximumVersion=''
DEBUG: 00:00:00.0043883 Calling New() : MethodName = 'GetFeatures'
DEBUG: 00:00:00.0044084 Verbose: True
DEBUG: 00:00:00.0044187 Debug: True
DEBUG: 00:00:00.0044280 Name: GitLab
DEBUG: 00:00:00.0052591 INVOKING PowerShell Fn Get-Feature with args that has length 0
DEBUG: 00:00:00.0083184 Done calling powershell «Get-Feature» «GitLabProvider»
VERBOSE: Importing package provider 'GitLab'.
Name Version DynamicOptions
---- ------- --------------
GitLab 1.3.8.0 Location, User
@akamac suggested: "You should run Import-PackageProvider GitLab" I've tried that and it fails with error below.
PS C:\temp> Import-PackageProvider GitLab
Import-PackageProvider : No match was found for the specified search criteria and provider name 'GitLab'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
At line:1 char:1
+ Import-PackageProvider GitLab
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (GitLab:String) [Import-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider
I tried that first, and when it failed that's what led me to use Find-PackageProvider instead. But even then, I had to search for GitLabProvider, because searching for just GitLab returns no results.
I think this is happening because on the Powershell Script Repository, the package is registered as "GitLabProvider". But when registered on the local PC, it calls itself "GitLab". After Install-PackageProvider has successfully installed the package, it tries to import it into the current session using the package name found on PSR. That fails and thus the warning message is generated. After installing the package, if I manually run Import-PackageProvider -Name GitLab, it imports successfully.