Edit

Share via


Import-PackageProvider

Adds Package Management package providers to the current session.

Syntax

Default (Default)

Import-PackageProvider
    [-Name] <String[]>
    [-RequiredVersion <String>]
    [-MinimumVersion <String>]
    [-MaximumVersion <String>]
    [-Force]
    [-ForceBootstrap]
    [<CommonParameters>]

Description

The Import-PackageProvider cmdlet adds one or more package providers to the current session. The provider that you import must be installed on the local computer.

To get a list of available providers, run Get-PackageProvider -ListAvailable. Note that a package provider name can be different from its module name.

Due to security reasons, PackageManagement requires C#-based providers to contain a provider.manifest. For more information on how to build a provider with provider.manifest injected, see the .csproj project files on https://github.com/oneget/oneget.

Examples

Example 1: Import a package provider from the local computer

PS C:\> Import-PackageProvider -Name "Nuget"

This command imports the Nuget provider after it has been installed on the local computer.

Example 2: Import a specific version of a package provider

PS C:\> Find-PackageProvider -Name "Nuget" -AllVersions
Install-PackageProvider -Name "Nuget" -RequiredVersion "2.8.5.201" -Force
Get-PackageProvider -ListAvailable
Import-PackageProvider -Name "Nuget" -RequiredVersion "2.8.5.201" -Verbose

This command finds, installs, and imports a specific version of the Nuget package provider.

Parameters

-Force

Forces the command to run without asking for user confirmation. Re-imports a package provider.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ForceBootstrap

Indicates that this cmdlet forces Package Management to automatically install the package provider.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MaximumVersion

Specifies the maximum allowed version of the package provider that you want to import. If you do not add this parameter, Import-PackageProvider imports the highest available version of the provider.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MinimumVersion

Specifies the minimum allowed version of the package provider that you want to import. If you do not add this parameter, Import-PackageProvider imports the highest available version of the package that also satisfies any maximum version that is specified using the MaximumVersion parameter.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Specifies one or more package provider names. Wildcards are not permitted.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-RequiredVersion

Specifies the exact version of the package provider that you want to import. If you do not add this parameter, Import-PackageProvider imports the highest available version of the provider that also satisfies any maximum version specified using the MaximumVersion parameter.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Microsoft.PackageManagement.Implementation.PackageProvider

You can pipe a PackageProvider object returned by Get-PackageProvider into Import-PackageProvider.

Notes

Important

As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. If you are not using TLS 1.2 or higher, you will receive an error when trying to access the PowerShell Gallery. Use the following command to ensure you are using TLS 1.2:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

For more information, see the announcement in the PowerShell blog.