Publish-Module
Publishes a specified module from the local computer to an online gallery.
語法
ModuleNameParameterSet (預設值)
Publish-Module
-Name <String>
[-RequiredVersion <String>]
[-NuGetApiKey <String>]
[-Repository <String>]
[-Credential <PSCredential>]
[-FormatVersion <Version>]
[-ReleaseNotes <String[]>]
[-Tags <String[]>]
[-LicenseUri <Uri>]
[-IconUri <Uri>]
[-ProjectUri <Uri>]
[-Exclude <String[]>]
[-Force]
[-AllowPrerelease]
[-SkipAutomaticTags]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ModulePathParameterSet
Publish-Module
-Path <String>
[-NuGetApiKey <String>]
[-Repository <String>]
[-Credential <PSCredential>]
[-FormatVersion <Version>]
[-ReleaseNotes <String[]>]
[-Tags <String[]>]
[-LicenseUri <Uri>]
[-IconUri <Uri>]
[-ProjectUri <Uri>]
[-Force]
[-SkipAutomaticTags]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Publish-Module
cmdlet publishes a module to an online NuGet-based gallery by using an API key,
stored as part of a user's profile in the gallery. You can specify the module to publish either by
the module's name, or by the path to the folder containing the module.
When you specify a module by name, Publish-Module
publishes the first module that would be found
by running Get-Module -ListAvailable <Name>
. If you specify a minimum version of a module to
publish, Publish-Module
publishes the first module with a version that is greater than or equal to
the minimum version that you have specified.
Publishing a module requires metadata that is displayed on the gallery page for the module. Required
metadata includes the module name, version, description, and author. Although most metadata is taken
from the module manifest, some metadata must be specified in Publish-Module
parameters, such as
Tag, ReleaseNote, IconUri, ProjectUri, and LicenseUri, because these parameters
match fields in a NuGet-based gallery.
The parameters that take module version numbers expect strings formatted as version numbers.
- Standard version numbers have a format of
x.y.z
where x, y, and z are numbers - Prerelease versions have a format of
x.y.z-<prerelease_label>
where the<prerelease_label>
is arbitrary string assigned to that release.
範例
Example 1: Publish a module
In this example, MyDscModule is published to the online gallery by using the API key to indicate the module owner's online gallery account. If MyDscModule is not a valid manifest module that specifies a name, version, description, and author, an error occurs.
Publish-Module -Name "MyDscModule" -NuGetApiKey "11e4b435-6cb4-4bf7-8611-5162ed75eb73"
Example 2: Publish a module with gallery metadata
In this example, MyDscModule is published to the online gallery by using the API key to indicate the module owner's gallery account. The additional metadata provided is displayed on the webpage for the module in the gallery. The owner adds two search tags for the module, relating it to Active Directory; a brief release note is added. If MyDscModule is not a valid manifest module that specifies a name, version, description, and author, an error occurs.
$parameters = @{
Name = "MyDscModule"
NuGetApiKey = "11e4b435-6cb4-4bf7-8611-5162ed75eb73"
LicenseUri = "http://contoso.com/license"
Tag = "Active Directory","DSC"
ReleaseNote = "Updated the ActiveDirectory DSC Resources to support adding users."
}
Publish-Module @parameters
參數
-AllowPrerelease
Allows modules marked as prerelease to be published.
參數屬性
類型: | SwitchParameter |
預設值: | False |
支援萬用字元: | False |
不要顯示: | False |
參數集
ModuleNameParameterSet
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-Confirm
Prompts you for confirmation before running the Publish-Module
.
參數屬性
類型: | SwitchParameter |
預設值: | False |
支援萬用字元: | False |
不要顯示: | False |
別名: | cf |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-Credential
Specifies a user account that has rights to publish a module for a specified package provider or source.
參數屬性
類型: | PSCredential |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | True |
來自剩餘引數的值: | False |
-Exclude
Defines files to exclude from the published module.
參數屬性
類型: | String[] |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
ModuleNameParameterSet
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-Force
Forces the command to run without asking for user confirmation.
參數屬性
類型: | SwitchParameter |
預設值: | False |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-FormatVersion
Accepts only valid values specified by the ValidateSet attribute.
For more information, see ValidateSet Attribute Declaration and ValidateSetAttribute.
參數屬性
類型: | Version |
預設值: | None |
接受的值: | 2.0 |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-IconUri
Specifies the URL of an icon for the module. The specified icon is displayed on the gallery webpage for the module.
參數屬性
類型: | Uri |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-LicenseUri
Specifies the URL of licensing terms for the module you want to publish.
參數屬性
類型: | Uri |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-Name
Specifies the name of the module that you want to publish. Publish-Module
searches for the
specified module name in $Env:PSModulePath
.
參數屬性
類型: | String |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
ModuleNameParameterSet
Position: | Named |
必要: | True |
來自管線的值: | False |
來自管線按屬性名稱的值: | True |
來自剩餘引數的值: | False |
-NuGetApiKey
Specifies the API key that you want to use to publish a module to the online gallery. The API key is part of your profile in the online gallery, and can be found on your user account page in the gallery. The API key is NuGet-specific functionality.
參數屬性
類型: | String |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-Path
Specifies the path to the module that you want to publish. This parameter accepts the path to the folder that contains the module. The folder must have the same name as the module.
參數屬性
類型: | String |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
ModulePathParameterSet
Position: | Named |
必要: | True |
來自管線的值: | False |
來自管線按屬性名稱的值: | True |
來自剩餘引數的值: | False |
-ProjectUri
Specifies the URL of a webpage about this project.
參數屬性
類型: | Uri |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-ReleaseNotes
Specifies a string containing release notes or comments that you want to be available to users of this version of the module.
參數屬性
類型: | String[] |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-Repository
Specifies the friendly name of a repository that has been registered by running
Register-PSRepository
. The repository must have a PublishLocation, which is a valid NuGet URI.
The PublishLocation can be set by running Set-PSRepository
.
參數屬性
類型: | String |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-RequiredVersion
Specifies the exact version of a single module to publish.
參數屬性
類型: | String |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
ModuleNameParameterSet
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-SkipAutomaticTags
Removes commands and resources from being included as tags. Skips automatically adding tags to a module.
參數屬性
類型: | SwitchParameter |
預設值: | False |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-Tags
Adds one or more tags to the module that you are publishing. Example tags include DesiredStateConfiguration, DSC, DSCResourceKit, or PSModule. Separate multiple tags with commas.
參數屬性
類型: | String[] |
預設值: | None |
支援萬用字元: | False |
不要顯示: | False |
參數集
(All)
Position: | Named |
必要: | False |
來自管線的值: | False |
來自管線按屬性名稱的值: | False |
來自剩餘引數的值: | False |
-WhatIf
Shows what would happen if the Publish-Module
runs. The cmdlet is not 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.
輸入
輸出
備註
PowerShell includes the following aliases for Publish-Module
:
- All platforms:
pumo
Publish-Module
runs on PowerShell 3.0 or later releases of PowerShell, on Windows 7 or Windows
2008 R2 and later releases of Windows.
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.
Publishing a module requires metadata that is displayed on the gallery page for the module. Required
metadata includes the module name, version, description, and author. Most metadata is taken from the
module manifest, but some metadata can be specified in Publish-Module
parameters, such as Tag,
ReleaseNote, IconUri, ProjectUri, and LicenseUri. For more information, see
Package manifest values that impact the PowerShell Gallery UI.