Save-Module

Saves a module and its dependencies on the local computer but doesn't install the module.

语法

NameAndPathParameterSet (默认值)

Save-Module
    [-Name] <String[]>
    [-Path] <String>
    [-MinimumVersion <String>]
    [-MaximumVersion <String>]
    [-RequiredVersion <String>]
    [-Repository <String[]>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Credential <PSCredential>]
    [-Force]
    [-AllowPrerelease]
    [-AcceptLicense]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

NameAndLiteralPathParameterSet

Save-Module
    [-Name] <String[]>
    -LiteralPath <String>
    [-MinimumVersion <String>]
    [-MaximumVersion <String>]
    [-RequiredVersion <String>]
    [-Repository <String[]>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Credential <PSCredential>]
    [-Force]
    [-AllowPrerelease]
    [-AcceptLicense]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

InputObjectAndLiteralPathParameterSet

Save-Module
    [-InputObject] <PSObject[]>
    -LiteralPath <String>
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Credential <PSCredential>]
    [-Force]
    [-AcceptLicense]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

InputObjectAndPathParameterSet

Save-Module
    [-InputObject] <PSObject[]>
    [-Path] <String>
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Credential <PSCredential>]
    [-Force]
    [-AcceptLicense]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

说明

The Save-Module cmdlet downloads a module and any dependencies from a registered repository. Save-Module downloads and saves the most current version of a module. The files are saved to a specified path on the local computer. The module isn't installed, but the contents are available for inspection by an administrator. The saved module can then be copied into the appropriate $env:PSModulePath location of the offline machine.

This is a proxy cmdlet for the Save-PSResource cmdlet in the Microsoft.PowerShell.PSResourceGet. For more information, see Save-PSResource

示例

Example 1: Save a module

In this example, a module and its dependencies are saved to the local computer.

Save-Module -Name PowerShellGet -Path C:\Test\Modules -Repository PSGallery
Get-ChildItem -Path C:\Test\Modules
    Directory: C:\Test\Modules

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         7/1/2019     13:31                PackageManagement
d-----         7/1/2019     13:31                PowerShellGet

Save-Module uses the Name parameter to specify the module, PowerShellGet. The Path parameter specifies where to store the downloaded module. The Repository parameter specifies a registered repository, PSGallery. After the download is finished, Get-ChildItem displays the contents of Path where the files are stored.

Example 2: Save a specific version of a module

This example shows how to use a parameter such as MaximumVersion, or RequiredVersion to specify a module version.

Save-Module -Name PowerShellGet -Path C:\Test\Modules -Repository PSGallery -MaximumVersion 2.1.0
Get-ChildItem -Path C:\Test\Modules\PowerShellGet\
    Directory: C:\Test\Modules\PowerShellGet

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         7/1/2019     13:40                2.1.0

Save-Module uses the Name parameter to specify the module, PowerShellGet. The Path parameter specifies where to store the downloaded module. The Repository parameter specifies a registered repository, PSGallery. MaximumVersion specifies that version 2.1.0 is downloaded and saved. After the download is finished, Get-ChildItem displays the contents of Path where the files are stored.

Example 3: Find and save a specific version of a module

In this example, a required module version is found in the repository and saved to the local computer.

Find-Module -Name PowerShellGet -Repository PSGallery -RequiredVersion 1.6.5 |
  Save-Module -Path C:\Test\Modules
Get-ChildItem -Path C:\Test\Modules\PowerShellGet
    Directory: C:\Test\Modules\PowerShellGet

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         7/1/2019     14:04                1.6.5

Find-Module uses the Name parameter to specify the module, PowerShellGet. The Repository parameter specifies a registered repository, PSGallery. RequiredVersion specifies version 1.6.5.

The object is sent down the pipeline to Save-Module. The Path parameter specifies where to store the downloaded module. After the download is finished, Get-ChildItem displays the contents of Path where the files are stored.

参数

-AcceptLicense

The proxy cmdlet ignores this parameter since it's not supported by Save-PSResource.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-AllowPrerelease

Allows you to save a module marked as a prerelease.

The proxy cmdlet maps this parameter to the Prerelease parameter of Save-PSResource.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

NameAndPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
NameAndLiteralPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Confirm

Prompts you for confirmation before running the Save-Module.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Credential

Specifies a user account that has rights to save a module.

参数属性

类型:PSCredential
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Force

The proxy cmdlet ignores this parameter since it's not supported by Save-PSResource.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputObject

Accepts a PSRepositoryItemInfo object. For example, output Find-Module to a variable and use that variable as the InputObject argument.

参数属性

类型:

PSObject[]

默认值:None
支持通配符:False
不显示:False

参数集

InputObjectAndLiteralPathParameterSet
Position:0
必需:True
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False
InputObjectAndPathParameterSet
Position:0
必需:True
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-LiteralPath

Specifies a path to one or more locations. The value of the LiteralPath parameter is used exactly as entered. No characters are interpreted as wildcards. If the path includes escape characters, enclose them in single quotation marks. PowerShell does not interpret any characters enclosed in single quotation marks as escape sequences.

The proxy cmdlet maps this parameter to the Path parameter of Save-PSResource.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:PSPath

参数集

NameAndLiteralPathParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
InputObjectAndLiteralPathParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-MaximumVersion

The proxy cmdlet uses the value of this parameter to create a NuGet version search string for use with the Version parameter of Save-PSResource.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

NameAndPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
NameAndLiteralPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-MinimumVersion

The proxy cmdlet uses the value of this parameter to create a NuGet version search string for use with the Version parameter of Save-PSResource.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

NameAndPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
NameAndLiteralPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Name

Specifies an array of names of modules to save.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

NameAndPathParameterSet
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
NameAndLiteralPathParameterSet
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Path

Specifies the location on the local computer to store a saved module. Accepts wildcard characters.

参数属性

类型:String
默认值:None
支持通配符:True
不显示:False

参数集

NameAndPathParameterSet
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
InputObjectAndPathParameterSet
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Proxy

The proxy cmdlet ignores this parameter since it's not supported by Save-PSResource.

参数属性

类型:Uri
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ProxyCredential

The proxy cmdlet ignores this parameter since it's not supported by Save-PSResource.

参数属性

类型:PSCredential
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Repository

Specifies the friendly name of a repository that has been registered by running Register-PSRepository. Use Get-PSRepository to display registered repositories.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

NameAndPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
NameAndLiteralPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-RequiredVersion

The proxy cmdlet uses the value of this parameter to create a NuGet version search string for use with the Version parameter of Save-PSResource.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

NameAndPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
NameAndLiteralPathParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-WhatIf

Shows what would happen if the Save-Module runs. The cmdlet isn't run.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:wi

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值: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.

输入

String

PSObject

String

Uri

PSCredential

输出

Object

备注

The PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. You must use TLS 1.2 or higher. Use the following command to ensure you are using TLS 1.2:

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