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>]
Description
Cmdlet Save-Module 會從已註冊的存放庫下載模組和任何相依性。
Save-Module 會下載並儲存模組的最新版本。 檔案會儲存到本機電腦上的指定路徑。 模組未安裝,但內容可供系統管理員檢查。 然後,可以將儲存的模組複製到離線電腦的適當 $env:PSModulePath 位置。
這是 Save-PSResource 中 Cmdlet 的 Proxy 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
Proxy Cmdlet 會忽略此參數,因為它不受 支援 Save-PSResource。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-AllowPrerelease
可讓您儲存標示為發行前版本的模組。
Proxy 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
Proxy Cmdlet 會忽略此參數,因為它不受 支援 Save-PSResource。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
接受 PSRepositoryItemInfo 物件。 例如,輸出 變數,並使用該變數作為 inputObject 自變數 。
| 類型: | PSObject[]
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
InputObjectAndLiteralPathParameterSet
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
InputObjectAndPathParameterSet
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-LiteralPath
指定通往一個或多個位置的路徑。
LiteralPath 參數的值與輸入完全相同。 不會將任何字元解譯為通配符。 如果路徑包含逸出字元,請以單引弧括住它們。 PowerShell 不會將以單引弧括住的任何字元解譯為逸出序列。
Proxy Cmdlet 會將此參數對應至 的 Save-PSResource 參數。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | PSPath |
參數集
NameAndLiteralPathParameterSet
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
InputObjectAndLiteralPathParameterSet
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-MaximumVersion
Proxy Cmdlet 會使用此參數的值來建立 NuGet 版本搜尋字串,以搭配 的 Version 參數 Save-PSResource使用。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
NameAndPathParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
NameAndLiteralPathParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-MinimumVersion
Proxy 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
Proxy Cmdlet 會忽略此參數,因為它不受 支援 Save-PSResource。
參數屬性
| 類型: | Uri
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-ProxyCredential
Proxy 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
Proxy 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