| external help file | Microsoft.PowerShell.PSResourceGet.dll-Help.xml |
|---|---|
| Module Name | Microsoft.PowerShell.PSResourceGet |
| ms.custom | 1.1.1 |
| ms.date | 05/14/2025 |
| online version | https://learn.microsoft.com/powershell/module/microsoft.powershell.psresourceget/publish-psresource?view=powershellget-3.x&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
Publishes a specified module from the local computer to PSResource repository.
Publish-PSResource [-ApiKey <String>] [-Repository <String>] [-Path] <String>
[-DestinationPath <String>] [-Credential <PSCredential>] [-SkipDependenciesCheck]
[-SkipModuleManifestValidate] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-WhatIf]
[-Confirm] [<CommonParameters>]
Publish-PSResource [-ApiKey <String>] [-Repository <String>] [-DestinationPath <String>]
[-Credential <PSCredential>] [-SkipDependenciesCheck] [-SkipModuleManifestValidate] [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] -NupkgPath <String> [-WhatIf] [-Confirm] [<CommonParameters>]
This cmdlet combines the functions of the Publish-Module and Publish-Script cmdlets from
PowerShellGet v2. Publish-PSResource publishes a resource from the local computer to an online
NuGet-based repository. You can specify the resource by a path containing the module or script
resource files or by pointing a prepackaged .nupkg file.
This example publishes the module TestModule to the repository registered with highest priority.
Publish-PSResource -Path c:\TestModuleThis example publishes the module TestModule to the PowerShell Gallery. The API key is a secret that's generated by the PowerShell Gallery for a user account.
Publish-PSResource -Path c:\TestModule -Repository PSGallery -APIKey '1234567'This example publishes the module Nupkg TestModule.nupkg to a repository named TestRepository.
Publish-PSResource -NupkgPath c:\TestModule.nupkg -Repository TestRepositorySpecifies the API key that you want to use to publish a resource to the online gallery.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies a user account that has rights to a specific repository.
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the path where the NuGet package .nupkg file should be saved. This parameter can be used
in conjunction with the Repository parameter to publish to a repository and also save the exact
same package to the local file system.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis is a dynamic parameter that's only available on the command line when you have supplied the
Path or Nupkg parameters and the Repository parameter for a ContainerRegistry
repository.
The value of the parameter is pre-pended to the package name. This information is only used for
publishing and isn't included in the package metadata. The module prefix controls the visibility of
the module, for example: internal, public, staging.
This parameter is only used when publishing to the Microsoft Artifact Registry (MAR).
Type: System.String
Parameter Sets: All
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalsePath to the .nupkg file to be published. The .nupkg file could have been created by a previous
run of Publish-PSResource with the DestinationPath parameter. Or, you can create the .nupkg
file using the Compress-PSResource command.
This parameter was added in v1.1.0-preview2 of Microsoft.PowerShell.PSResourceGet.
Type: System.String
Parameter Sets: NupkgPathParameterSet
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe path to the module or script file or the path to a folder containing the module or script file
to be published. The cmdlet packages all files in the folder into a .nupkg file before publishing
to the repository.
Type: System.String
Parameter Sets: PathParameterSet
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe URL to a proxy server used to access repositories outside of your network.
Type: System.Uri
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe credentials required to use the proxy server.
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the repository to publish to.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseBypasses the default check that all dependencies are present in the target repository.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSkips validating the module manifest before publishing.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalsePrompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseShows what would happen if the cmdlet runs. The cmdlet isn't run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
The module defines pbres as an alias for Publish-PSResource.
Fileshare-based repository have no metadata about the resources. Therefore, there is no way to check for dependencies.