Partager via


Save-Package

Saves packages to the local computer without installing them.

Syntaxe

PackageBySearch

Save-Package
    [-Name] <String[]>
    [-RequiredVersion <String>]
    [-MinimumVersion <String>]
    [-MaximumVersion <String>]
    [-Source <String[]>]
    [-Path <String>]
    [-LiteralPath <String>]
    [-Credential <PSCredential>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-ProviderName <String[]>]
    [<CommonParameters>]

PackageByInputObject

Save-Package
    -InputObject <SoftwareIdentity>
    [-Path <String>]
    [-LiteralPath <String>]
    [-Credential <PSCredential>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

NuGet:PackageByInputObject

Save-Package
    [-Path <String>]
    [-LiteralPath <String>]
    [-Credential <PSCredential>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-ConfigFile <String>]
    [-SkipValidate]
    [-Headers <String[]>]
    [-FilterOnTag <String[]>]
    [-Contains <String>]
    [-AllowPrereleaseVersions]
    [<CommonParameters>]

NuGet

Save-Package
    [-Path <String>]
    [-LiteralPath <String>]
    [-Credential <PSCredential>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-ConfigFile <String>]
    [-SkipValidate]
    [-Headers <String[]>]
    [-FilterOnTag <String[]>]
    [-Contains <String>]
    [-AllowPrereleaseVersions]
    [<CommonParameters>]

PowerShellGet:PackageByInputObject

Save-Package
    [-Path <String>]
    [-LiteralPath <String>]
    [-Credential <PSCredential>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-AllowPrereleaseVersions]
    [-PackageManagementProvider <String>]
    [-PublishLocation <String>]
    [-ScriptSourceLocation <String>]
    [-ScriptPublishLocation <String>]
    [-Type <String>]
    [-Filter <String>]
    [-Tag <String[]>]
    [-Includes <String[]>]
    [-DscResource <String[]>]
    [-RoleCapability <String[]>]
    [-Command <String[]>]
    [-AcceptLicense]
    [<CommonParameters>]

PowerShellGet

Save-Package
    [-Path <String>]
    [-LiteralPath <String>]
    [-Credential <PSCredential>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-AllowPrereleaseVersions]
    [-PackageManagementProvider <String>]
    [-PublishLocation <String>]
    [-ScriptSourceLocation <String>]
    [-ScriptPublishLocation <String>]
    [-Type <String>]
    [-Filter <String>]
    [-Tag <String[]>]
    [-Includes <String[]>]
    [-DscResource <String[]>]
    [-RoleCapability <String[]>]
    [-Command <String[]>]
    [-AcceptLicense]
    [<CommonParameters>]

Description

The Save-Package cmdlet saves packages to the local computer but doesn't install the packages. This cmdlet saves the newest version of a package unless you specify a RequiredVerion. The Path and LiteralPath parameters are mutually exclusive, and cannot be added to the same command.

Exemples

Example 1: Save a package to the local computer

This example saves the newest version of the package to a directory on the local computer. The package's dependencies are download with the package.

PS> Save-Package -Name NuGet.Core -ProviderName NuGet -Path C:\LocalPkg
Name                    Version    Source    Summary
----                    -------    ------    -------
Microsoft.Web.Xdt       3.0.0      Nuget     Microsoft Xml Document Transformation (XDT) enables...
NuGet.Core              2.14.0     Nuget     NuGet.Core is the core framework assembly for NuGet...

Save-Package uses the Name parameter to specify the package. The package is downloaded from the repository specified by the ProviderName parameter. The Path parameter determines where the package is saved.

Example 2: Save a specific package version

This example specifies the package version and saves it to a directory on the local computer.

PS> Save-Package -Name NuGet.Core -RequiredVersion 2.9.0 -ProviderName NuGet -Path C:\LocalPkg
Name                    Version    Source    Summary
----                    -------    ------    -------
Microsoft.Web.Xdt       3.0.0      Nuget     Microsoft Xml Document Transformation (XDT) enables...
NuGet.Core              2.9.0      Nuget     NuGet.Core is the core framework assembly for NuGet...

Save-Package uses the Name parameter to specify the package. RequiredVersion indicates a specific package version. The package is downloaded from the repository specified by the ProviderName parameter. The Path parameter determines where the package is saved.

Example 3: Use Find-Package to save a package

This command uses Find-Package to locate the newest version of the package and sends the object to Save-Package.

PS> Find-Package -Name NuGet.Core -ProviderName NuGet | Save-Package -Path C:\LocalPkg

Find-Package uses the Name parameter to specify the package. The package is downloaded from the repository specified by the ProviderName parameter. The object is sent down the pipeline to Save-Package. The Path parameter determines where the package is saved.

Example 4: Save and install the package

The newest version of the package and its dependencies are downloaded and installed on the local computer.

PS> Save-Package -Name NuGet.Core -ProviderName NuGet -Path C:\LocalPkg
PS> Install-Package C:\LocalPkg\NuGet.Core.2.14.0.nupkg

Save-Package downloads the package file and its dependencies to the local computer. Install-Package installs the package and dependencies from the specified directory.

Paramètres

-AcceptLicense

Automatically accept the license agreement during installation if the package requires it.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AllowPrereleaseVersions

Allows packages marked as Prerelease to be saved.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AllVersions

Indicates that this cmdlet saves all available versions of the package.

Parameter properties

Type:SwitchParameter
Valeur par défaut: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

-Command

Specifies one or more commands included in the package.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ConfigFile

Specifies a configuration File.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Valeur par défaut:False
Supports wildcards:False
DontShow:False
Alias:cf

Parameter sets

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

-Contains

Save-Package gets objects if any item in the object's property values are an exact match for the specified value.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Credential

Specifies a user account that has permission to save a package from a specified package provider or source.

Parameter properties

Type:PSCredential
Valeur par défaut: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

-DscResource

Specifies one or more Desired State Configuration (DSC) resources for the package.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Filter

Specifies a filter for the package.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-FilterOnTag

Specifies the tag that filters the results. Results that don't contain the specified tag are excluded.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Forces the command to run without asking for user confirmation.

Parameter properties

Type:SwitchParameter
Valeur par défaut: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 Save-Package forces PackageManagement to automatically install the package provider for the specified package.

Parameter properties

Type:SwitchParameter
Valeur par défaut: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

-Headers

Specifies the headers for the package.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Includes

Indicates the resources that the package includes.

Parameter properties

Type:

String[]

Valeur par défaut:None
Valeurs acceptées:DscResource, Cmdlet, Function, Workflow, RoleCapability
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

A software ID object that represents the package that you want to save. Software IDs are part of the results of the Find-Package cmdlet.

Parameter properties

Type:Microsoft.PackageManagement.Packaging.SoftwareIdentity
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageByInputObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-LiteralPath

Specifies the literal path to which you want to save the package. You cannot add both this parameter and the Path parameter to the same command.

Parameter properties

Type:String
Valeur par défaut: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 version of the package that you want to save.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MinimumVersion

Specifies the minimum version of the package that you want to find.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
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 names.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PackageManagementProvider

Specifies a package management provider.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Path

Specifies the location on the local computer to store the package.

Parameter properties

Type:String
Valeur par défaut: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

-ProviderName

Specifies one or more provider names.

Parameter properties

Type:

String[]

Valeur par défaut:None
Valeurs acceptées:Bootstrap, NuGet, PowerShellGet
Supports wildcards:False
DontShow:False
Alias:Provider

Parameter sets

PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Proxy

Specifies a proxy server for the request, rather than a direct connection to the internet resource.

Parameter properties

Type:Uri
Valeur par défaut: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

-ProxyCredential

Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter.

Parameter properties

Type:PSCredential
Valeur par défaut: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

-PublishLocation

Specifies the publish location.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RequiredVersion

Specifies the exact version of the package to save.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RoleCapability

Specifies an array of role capabilities.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ScriptPublishLocation

Specifies the script publish location.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ScriptSourceLocation

Specifies the script source location.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SkipValidate

Switch that skips validating the credentials of a package.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Source

Specifies one or more package sources.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Tag

Specifies a tag to search for within the package metadata.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Type

Specifies whether to search for packages with a module, a script, or either.

Parameter properties

Type:String
Valeur par défaut:None
Valeurs acceptées:Module, Script, All
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Valeur par défaut:False
Supports wildcards:False
DontShow:False
Alias:wi

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.

Entrées

Microsoft.PackageManagement.Packaging.SoftwareIdentity

You can pipe a SoftwareIdentity object to this cmdlet.

Sorties

None

This cmdlet returns no output.

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.