Save-Module
将模块及其依赖项保存在本地计算机上,但不安装该模块。
语法
NameAndPathParameterSet (默认值)
Save-Module
[-Name] <String[]>
-Path <String>
[-MinimumVersion <Version>]
[-MaximumVersion <Version>]
[-RequiredVersion <Version>]
[-Repository <String[]>]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
NameAndLiteralPathParameterSet
Save-Module
[-Name] <String[]>
-LiteralPath <String>
[-MinimumVersion <Version>]
[-MaximumVersion <Version>]
[-RequiredVersion <Version>]
[-Repository <String[]>]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Save-Module
[-InputObject] <PSObject[]>
-LiteralPath <String>
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Save-Module
[-InputObject] <PSObject[]>
-Path <String>
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Save-Module cmdlet 从已注册的存储库下载模块和任何依赖项。
Save-Module 下载并保存模块的最新版本。 这些文件将保存到本地计算机上的指定路径。 模块未安装,但内容可供管理员检查。
Get-PSRepository 显示本地计算机的已注册存储库。 可以使用 Find-Module cmdlet 搜索已注册的存储库。
示例
示例 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 显示存储文件的 路径 的内容。
参数
-Confirm
在运行 Save-Module之前,提示你进行确认。
参数属性
| 类型: | SwitchParameter
|
| 默认值: | False |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | cf |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Force
Save-Module强制运行而不要求用户确认。
参数属性
| 类型: | SwitchParameter
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(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 不会将用单引号括起的任何字符解释为转义序列。
参数属性
| 类型: | String
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
InputObjectAndLiteralPathParameterSet
| Position: | Named |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-MaximumVersion
指定要保存的模块的最大版本或最新版本。
不能在同一命令中使用 MaximumVersion 和 RequiredVersion 参数。
参数属性
| 类型: | Version
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NameAndPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-MinimumVersion
指定要保存的单个模块的最低版本。 如果尝试安装多个模块,则无法添加此参数。
MinimumVersion 和 RequiredVersion 参数不能在同一命令中使用。
参数属性
| 类型: | Version
|
| 默认值: | 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 |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
InputObjectAndPathParameterSet
| Position: | 1 |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | 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
指定要保存的模块的确切版本号。
参数属性
| 类型: | Version
|
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NameAndPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
NameAndLiteralPathParameterSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-WhatIf
显示 Save-Module 运行时会发生什么情况。 cmdlet 未能运行。
参数属性
| 类型: | SwitchParameter
|
| 默认值: | False |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | 无线 |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。