Save-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>]
Save-Module
[-InputObject] <PSObject[]>
-LiteralPath <String>
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-Force]
[-AcceptLicense]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Save-Module
[-InputObject] <PSObject[]>
[-Path] <String>
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-Force]
[-AcceptLicense]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Save-Module cmdlet 从已注册的存储库下载模块和任何依赖项。
Save-Module 下载并保存模块的最新版本。 这些文件将保存到本地计算机上的指定路径。 模块未安装,但内容可供管理员检查。 然后,可以将保存的模块复制到脱机计算机的相应 $env:PSModulePath 位置。
这是 Save-PSResource 中 cmdlet 的代理 cmdlet。 有关详细信息,请参阅 Save-PSResource
示例
示例 1:保存模块
在此示例中,模块及其依赖项保存到本地计算机。
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 使用 Name 参数来指定模块,PowerShellGet。
Path 参数指定存储下载的模块的位置。
Repository 参数指定已注册的存储库,PSGallery。 下载完成后,Get-ChildItem 显示存储文件的 路径 的内容。
示例 2:保存模块的特定版本
此示例演示如何使用 MaximumVersion等参数,或 RequiredVersion 指定模块版本。
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 使用 Name 参数来指定模块,PowerShellGet。
Path 参数指定存储下载的模块的位置。
Repository 参数指定已注册的存储库,PSGallery。
MaximumVersion 指定下载并保存版本 2.1.0。 下载完成后,Get-ChildItem 显示存储文件的 路径 的内容。
示例 3:查找并保存模块的特定版本
在此示例中,在存储库中找到所需的模块版本,并保存到本地计算机。
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 使用 Name 参数来指定模块,PowerShellGet。
Repository 参数指定已注册的存储库,PSGallery。
RequiredVersion 指定版本 1.6.5。
将对象向下发送到管道 Save-Module。
Path 参数指定存储下载的模块的位置。 下载完成后,Get-ChildItem 显示存储文件的 路径 的内容。
参数
-AcceptLicense
代理 cmdlet 忽略此参数,因为它不受支持 Save-PSResource。
参数属性
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-AllowPrerelease
允许保存标记为预发行版的模块。
代理 cmdlet 将此参数映射到 预发行版 参数 Save-PSResource。
参数属性
参数集
NameAndPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Confirm
在运行 Save-Module之前,提示你进行确认。
参数属性
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Credential
指定有权保存模块的用户帐户。
参数属性
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Force
代理 cmdlet 忽略此参数,因为它不受支持 Save-PSResource。
参数属性
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
接受 PSRepositoryItemInfo 对象。 例如,输出 Find-Module 变量,并将该变量用作 InputObject 参数。
| 类型: | PSObject[]
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
InputObjectAndLiteralPathParameterSet
| Position: | 0 |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
InputObjectAndPathParameterSet
| Position: | 0 |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-LiteralPath
指定通向一个或多个位置的路径。
LiteralPath 参数的值与输入完全相同。 不会将任何字符解释为通配符。 如果路径包含转义字符,请将它们括在单引号中。 PowerShell 不会将用单引号括起的任何字符解释为转义序列。
代理 cmdlet 将此参数映射到 Path 参数 Save-PSResource。
参数属性
| 类型: | String
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | PSPath |
参数集
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
InputObjectAndLiteralPathParameterSet
| Position: | Named |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-MaximumVersion
代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Version 参数 Save-PSResource一起使用。
参数属性
| 类型: | String
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NameAndPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-MinimumVersion
代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Version 参数 Save-PSResource一起使用。
参数属性
| 类型: | String
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NameAndPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Name
指定要保存的模块名称数组。
参数属性
| 类型: | String[]
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NameAndPathParameterSet
| Position: | 0 |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
NameAndLiteralPathParameterSet
| Position: | 0 |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Path
指定要存储已保存模块的本地计算机上的位置。 接受通配符。
参数属性
| 类型: | String
|
| 默认值: | None |
| 支持通配符: | True |
| 不显示: | False |
参数集
NameAndPathParameterSet
| Position: | 1 |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
InputObjectAndPathParameterSet
| Position: | 1 |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Proxy
代理 cmdlet 忽略此参数,因为它不受支持 Save-PSResource。
参数属性
| 类型: | Uri
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-ProxyCredential
代理 cmdlet 忽略此参数,因为它不受支持 Save-PSResource。
参数属性
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Repository
指定通过运行 Register-PSRepository注册的存储库的友好名称。 使用 Get-PSRepository 显示已注册的存储库。
参数属性
| 类型: | String[]
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NameAndPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-RequiredVersion
代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Version 参数 Save-PSResource一起使用。
参数属性
| 类型: | String
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NameAndPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-WhatIf
显示 Save-Module 运行时会发生什么情况。 cmdlet 未能运行。
参数属性
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输出
备注
PowerShell 库不再支持传输层安全性(TLS)版本 1.0 和 1.1。 必须使用 TLS 1.2 或更高版本。 使用以下命令确保使用的是 TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12