Professional Documents
Culture Documents
The PowerShell Gallery is the central repository for PowerShell content. In it, you can
find
PowerShell scripts, modules containing PowerShell cmdlets and Desired State
Configuration (DSC)
resources. Some of these packages are authored by Microsoft, and
others are authored by the
PowerShell community.
The PowerShellGet module contains cmdlets for discovering, installing, updating, and
publishing
PowerShell packages from the PowerShell Gallery. These packages can
contain artifacts such as
Modules, DSC Resources, Role Capabilities, and Scripts. Make
sure you have the latest version of
PowerShellGet installed.
Install PowerShellGet
Update PowerShellGet for Windows PowerShell
Giving feedback
Provide feedback and report issues in the GitHub repository . To see the current status
of the
PowerShell Gallery services, see the PowerShell Gallery Status page on GitHub.
The PowerShellGet module
Article • 06/30/2023
The PowerShellGet module contains cmdlets for discovering, installing, updating, and
publishing
PowerShell packages from the PowerShell Gallery . These packages can
contain artifacts such as
Modules, DSC Resources, and Scripts.
Supported versions:
Version history
Windows PowerShell 5.1 comes with version 1.0.0.1 of PowerShellGet and
PackageManagement preinstalled.
) Important
PowerShell 7.0.4, PowerShell 7.1.1, and higher shipped with PowerShellGet 2.2.5
and
PackageManagement 1.4.7.
See also
Install PowerShellGet
PowerShellGet cmdlet reference
Microsoft.PowerShell.PSResourceGet cmdlet reference
How to Install PowerShellGet
Article • 07/26/2023
Prerequisites
Ensure that you have a version of PowerShellGet and PackageManagement newer than
1.0.0.1 installed. The latest stable versions are 2.2.5 for PowerShellGet and 1.4.8.1 for
PackageManagement.
If you're running Windows PowerShell 5.1 with PowerShellGet 1.0.0.1, see Update
PowerShellGet for Windows PowerShell 5.1.
To access the PowerShell Gallery, you must use Transport Layer Security (TLS) 1.2 or
higher. Use the following command to enable TLS 1.2 in your PowerShell session.
PowerShell
[Net.ServicePointManager]::SecurityProtocol =
[Net.ServicePointManager]::SecurityProtocol -bor
[Net.SecurityProtocolType]::Tls12
Add this command to your PowerShell profile script to ensure TLS 1.2 is configured for
every PowerShell session. For more information about profiles, see about_Profiles.
If you're running PowerShell 6.0 or later, you already have a newer version of
PowerShellGet and PackageManagement installed. You can upgrade to a newer version
if necessary or install the preview release. You should always install the latest stable
release.
PowerShell
The following output shows that the latest stable version needs to be installed.
Output
PowerShell
PowerShell
Windows PowerShell 5.1 comes with version 1.0.0.1 of the PowerShellGet and
PackageManagement
preinstalled. This version of PowerShellGet has a limited features
and must be updated to work
with the PowerShell Gallery. To be supported, you must
update to the latest version.
Prerequisites
PowerShellGet requires .NET Framework 4.5 or above. For more information, see
Install the .NET Framework for developers.
To access the PowerShell Gallery, you must use Transport Layer Security (TLS) 1.2 or
higher. Use
the following command to enable TLS 1.2 in your PowerShell session.
PowerShell
[Net.ServicePointManager]::SecurityProtocol =
[Net.ServicePointManager]::SecurityProtocol -bor
[Net.SecurityProtocolType]::Tls12
Add this command to your PowerShell profile script to ensure TLS 1.2 is configured
for every
PowerShell session. For more information about profiles, see
about_Profiles.
than the
currently installed module. However, this cmdlet only works if the
previous version was installed
using Install-Module .
To update the preinstalled module you must use Install-Module . After you have
installed the new
version from the PowerShell Gallery, you can use Update-Module to
install newer releases.
Windows PowerShell 5.1 comes with PowerShellGet version 1.0.0.1, which doesn't
include the NuGet
provider. The provider is required by PowerShellGet when working
with the PowerShell Gallery.
7 Note
The following commands must be run from an elevated PowerShell session. Right-
click the PowerShell
icon and choose Run as administrator to start an elevated
session.
PowerShell
After you have installed the provider you should be able to use any of the
PowerShellGet
cmdlets with the PowerShell Gallery.
PowerShell
Install-Module prompts you to install the NuGet provider. Type Y to install the
provider.
Output
or 'C:\Users\user1\AppData\Local\PackageManagement\ProviderAssemblies'.
You can also install the
We also recommend that you register the PowerShell Gallery as a trusted repository. Use
the
following command:
PowerShell
PowerShellGet requires .NET Framework 4.5 or above. For more information, see
Install
the .NET Framework for developers.
) 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:
PowerShell
[Net.ServicePointManager]::SecurityProtocol =
[Net.ServicePointManager]::SecurityProtocol -bor
[Net.SecurityProtocolType]::Tls12
The Save-Module cmdlet is used in both sets of instructions. Save-Module downloads and
saves a
module and any dependencies from a registered repository. The module's most
current version is saved
to a specified path on the local computer, but isn't installed. To
install the modules in PowerShell
3.0 or 4.0, copy the saved module folders to
$env:ProgramFiles\WindowsPowerShell\Modules .
PowerShell 3.0 and PowerShell 4.0 only supported one version of a module. Starting
in PowerShell
5.0, modules are installed in <modulename>\<version> folders. This
allows you to install
multiple versions side-by-side. After downloading the module
using Save-Module you must copy the
files from the <modulename>\<version> folder
to the <modulename> folder on the destination
machine, as shown in the instructions
below.
PowerShell
$NewPSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath',
'Machine') +
";$env:ProgramFiles\WindowsPowerShell\Modules"
[Environment]::SetEnvironmentVariable('PSModulePath', $NewPSModulePath,
'Machine')
The updated value of $env:PSModulePath isn't available in the current session. You must
open a
new PowerShell session.
7 Note
PowerShell
3. Reopen the PowerShell console with elevated permissions and run the following
command.
PowerShell
'PowerShellGet', 'PackageManagement' | % {
$targetDir = "$env:ProgramFiles\WindowsPowerShell\Modules\$_"
Prerequisites
Set up a SecretManagement vault
Create a credential to be used with Artifactory
7 Note
This example uses SecretStore, but you can use any SecretManagement extension
vault and
with any repository.
Use Get-SecretInfo to verify that the vault contains the credential you need.
PowerShell
Get-SecretInfo
Output
PowerShell
$registerPSResourceRepositorySplat = @{
Name = 'artifactory'
Uri = 'https://myaccount.jfrog.io/artifactory/api/nuget/v3/myrepository'
Trusted = $true
CredentialInfo =
[Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo]::new(
'SecretStore', 'JFrogCred')
Register-PSResourceRepository @registerPSResourceRepositorySplat
PowerShell
Output
Name Uri
Trusted Priority
---- ---
------- --------
artifactory https://myaccount.jfrog.io/artifactory/api/nuget/v3/myrepository
True 50
PSGallery https://www.powershellgallery.com/api/v2
False 50
PowerShell
Once you have provided the credential, PowerShellGet reuses the credential for
subsequent
commands that target the same repository. The following examples show
how to find and install a
resource. Notice that the credential isn't required.
PowerShell
Output
PowerShell
You don't need credentials to search, download, or install packages from the PowerShell
Gallery. You must create an account and API key to publish packages to the PowerShell
Gallery. For more information, see Creating and publishing an item.
NuGet.org
NuGet.org is a public host of NuGet packages used by millions of .NET and .NET Core
developers every day. NuGet.org provides a NuGet repository that uses the NuGet v3
protocol.
PowerShell
$params = @{
Name = 'NuGetGallery'
Uri = 'https://api.nuget.org/v3/index.json'
}
Register-PSResourceRepository @params
You don't need credentials to search, download, or install packages from NuGet.org. You
must create an account and API key to publish packages to NuGet.org. For more
information about getting a NuGet API key, see Quickstart: Create and publish a NuGet
package.
NuGet.org limitations
The Microsoft.PowerShell.PSResourceGet module doesn't support the following
scenarios for NuGet.org repositories:
Publishing to NuGet.org
You don't need to use the Credential parameter of the Publish-PSResource cmdlet, but
you must use the ApiKey parameter. You can provide credentials, but NuGet.org doesn't
use them. To create an API key, see How to publish NuGet packages. For example:
PowerShell
$publishPSResourceSplat = @{
Path = 'D:\MyModule'
Repository = 'AzArtifactFeed'
ApiKey = '<nuget-api-key>'
}
Publish-PSResource @publishPSResourceSplat
U Caution
You should never use plaintext credentials in a script. Use the SecretManagement
module or other methods to store and retrieve your credentials securely. For more
information, see Overview of the SecretManagement and SecretStore modules.
Azure Artifacts
Azure Artifacts is a feature of Azure DevOps. Azure Artifacts enables developers to share
their code efficiently and manage all their packages from one place. With Azure
Artifacts, developers can publish packages to their feeds and share it within the same
team, across organizations, and even publicly.
Azure Artifacts supports the NuGet v3 protocol. Azure Artifacts feed URIs use the
following format:
https://dev.azure.com/<organization-name>/<project-name>/_packaging/<feed-
name>/v3/index.json
Substitute the placeholder values with your organization, project, and feed names. For
example, use the following command to register an Azure Artifacts feed as a PSResource
repository:
PowerShell
$params = @{
Name = 'MyAdoFeed'
Uri =
'https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyFeed/nuget/v3/index
.json'
}
Register-PSResourceRepository @params
Azure DevOps allows you to create public or private feeds for your Azure Artifacts. You
don't need credentials to search, download, or install packages from an Azure Artifacts
public feed. To publish artifacts or access private feeds, you must have an account and
an API key. For more information about getting an API key, see Connect to feed as a
PowerShell repository.
PowerShell
For this example <personal-access-token> is the token you created for publishing.
<username> is your Azure DevOps user name.
U Caution
You should never use plaintext credentials in a script. Use the SecretManagement
module or other methods to store and retrieve your credentials securely. For more
information, see Overview of the SecretManagement and SecretStore modules.
GitHub Packages
GitHub Packages is a software package hosting service that allows you to host your
software packages privately or publicly and use packages as dependencies in your
projects. For more information, see Introduction to GitHub Packages .
The GitHub Packages feed is a NuGet repository that uses the NuGet v3 protocol. The
feed URI has the following format:
https://nuget.pkg.github.com/<namespace>/index.json . Replace <namespace> with the
name of the personal account or organization to which your packages are scoped. For
example, use the following command to register an GitHub Packages feed as a
PSResource repository:
PowerShell
$params = @{
Name = 'MyGitHubFeed'
Uri = 'https://nuget.pkg.github.com/MyGitHubOrg/index.json'
}
Register-PSResourceRepository @params
The Github Packages service doesn't support NuGet feeds that are scoped to a
repository. The feed must be associated with a user account or organization.
You must use credentials for all operations with a GitHub Packages feed. For more
information, see the Authenticating to GitHub Packages section of Working with the
NuGet registry .
If you use the Credential parameter, the value must be a PSCredential object that
contains your username and the PAT. For this example <personal-access-token> is the
token you created for publishing. <username> is your GitHub username.
PowerShell
$patToken = ConvertTo-SecureString -String '<personal-access-token>' -
AsPlainText -Force
$Credential = [System.Management.Automation.PSCredential]::new('<username>',
$patToken)
$publishPSResourceSplat = @{
Path = 'D:\MyModule'
Repository = 'MyGitHubFeed'
Credential = $Credential
}
Publish-PSResource @publishPSResourceSplat
If you use the ApiKey parameter, the value must be the plaintext PAT. For example:
PowerShell
$publishPSResourceSplat = @{
Path = 'D:\MyModule'
Repository = 'MyGitHubFeed'
ApiKey = '<personal-access-token>'
}
Publish-PSResource @publishPSResourceSplat
U Caution
You should never use plaintext credentials in a script. Use the SecretManagement
module or other methods to store and retrieve your credentials securely. For more
information, see Overview of the SecretManagement and SecretStore modules.
JFrog Artifactory
JFrog Artifactory is a hosting service for NuGet repositories. Artifactory feeds use the
NuGet v3 protocol. The feed URI has the following format:
https://<jfrog-account>.jfrog.io/artifactory/api/nuget/v3/nuget/index.json .
Replace <jfrog-account> with the name of your JFrog account. For example, use the
following command to register an Artifactory feed as a PSResource repository:
PowerShell
$params = @{
Name = 'MyJFrogFeed'
Uri =
'https://myjfrogaccount.jfrog.io/artifactory/api/nuget/v3/nuget/index.json'
}
Register-PSResourceRepository @params
You must use credentials for all operations with a JFrog Artifactory feed. For more
information, see Creating Access Tokens in Artifactory .
PowerShell
For this example <jfrog-access-token> is the token you created for publishing. <email-
address> is your email address associated with your JFrog account.
U Caution
You should never use plaintext credentials in a script. Use the SecretManagement
module or other methods to store and retrieve your credentials securely. For more
information, see Overview of the SecretManagement and SecretStore modules.
MyGet.org
MyGet.org is a hosting service for NuGet repositories.
https://www.myget.org/F/<feedname>/api/v3/index.json
Replace <feedname> with the name of your MyGet feed. For example, use the following
command to register a MyGet feed as a PSResource repository:
PowerShell
$params = @{
Name = 'PublicMyGetFeed'
Uri = 'https://www.myget.org/F/mypackagefeed/api/v3/index.json'
}
Register-PSResourceRepository @params
MyGet allows you to create public or private feeds. You don't need credentials to search,
download, or install packages from a public MyGet feed. To publish artifacts or access
private feeds, you must have an account and an API key. For more information about,
see MyGet Security .
MyGet limitations
The Microsoft.PowerShell.PSResourceGet module doesn't support the following
scenarios for MyGet repositories:
For example:
PowerShell
$publishPSResourceSplat = @{
Path = 'D:\MyModule'
Repository = 'MyGitHubFeed'
ApiKey = '<personal-access-token>'
}
Publish-PSResource @publishPSResourceSplat
U Caution
You should never use plaintext credentials in a script. Use the SecretManagement
module or other methods to store and retrieve your credentials securely. For more
information, see Overview of the SecretManagement and SecretStore modules.
File-share-based repositories
You can create your own package repository as a local file share. For more information,
see Working with local PSRepositories. You access file-share-based repositories using
local filesystem APIs or remote filesystem protocols, such as SMB or NFS.
The permissions set by the filesystem and the file sharing protocol control access to the
files. You can't use the Credential parameter of the
Microsoft.PowerShell.PSResourceGet cmdlets to access to the files using alternate user
credentials.
http://<server-host-name>/nuget
7 Note
PowerShell
$params = @{
Name = 'SelfHostedNuGet'
Uri = 'https://host.contoso.net/nuget'
}
Register-PSResourceRepository @params
You don't need credentials to search, download, or install packages from your self-
hosted server.
parameter is ignored. The cmdlet returns all modules and scripts that match the
name.
Search by command or DSC resource name, for example:
Find-PSResource -Command commandname
PowerShell
$publishPSResourceSplat = @{
Path = 'D:\MyModule'
Repository = 'MyGitHubFeed'
ApiKey = '<apikey>'
}
Publish-PSResource @publishPSResourceSplat
U Caution
You should never use plaintext credentials in a script. Use the SecretManagement
module or other methods to store and retrieve your credentials securely. For more
information, see Overview of the SecretManagement and SecretStore modules.
Getting Started with the PowerShell
Gallery
Article • 04/17/2023
The PowerShell Gallery is a package repository containing scripts, modules, and DSC
resources you
can download and leverage. You use the cmdlets in the PowerShellGet
module to install packages
from the PowerShell Gallery. You don't need to sign in to
download items from the PowerShell
Gallery.
7 Note
It's possible to download a package from the PowerShell Gallery directly, but this
isn't a
recommended approach. For more details, see Manual Package Download.
You can filter results from the Gallery using the following parameters:
Name
AllVersions
MinimumVersion
RequiredVersion
Tag
Includes
DscResource
RoleCapability
Command
Filter
If you're only interested in discovering specific DSC resources in the Gallery, you can run
the
Find-DscResource cmdlet. Find-DscResource returns data on DSC resources
contained in the Gallery.
Because DSC resources are always delivered as part of a
module, you still need to run
Install-Module to install those DSC resources.
If you discover a package that you feel isn't published in good faith, click Report Abuse
on
that package's page.
If you're running Find-Module or Find-Script , you can view this data in the returned
PSGetModuleInfo object. The following example returns data on the PSReadLine
module in the
Gallery.
PowerShell
Inspect
To download a package from the Gallery for inspection, run either the Save-Module or
Save-Script
cmdlet, depending on the package type. This lets you save the package
Some of these packages are authored by Microsoft, and others are authored by the
PowerShell
community. Microsoft recommends that you review the contents and code
of packages on this gallery
before installation.
If you discover a package that you feel isn't published in good faith, click Report Abuse
on
that package's page.
Install
To install a package from the Gallery for use, run either the Install-Module or Install-
Script
cmdlet, depending on the package type.
default.
This requires an administrator account. If you add the -Scope CurrentUser
parameter, the module is
installed to $HOME\Documents\WindowsPowerShell\Modules .
default.
This requires an administrator account. If you add the -Scope CurrentUser
parameter, the script is
installed to $HOME\Documents\WindowsPowerShell\Scripts .
Deploy
To deploy a package from the PowerShell Gallery to Azure Automation, click Azure
Automation,
then click Deploy to Azure Automation on the package details page. You
are redirected to the
Azure Management Portal where you sign in using your Azure
account credentials. Note that
deploying packages with dependencies deploys all the
dependencies to Azure Automation. The 'Deploy
to Azure Automation' button can be
disabled by adding the AzureAutomationNotSupported tag to
your package metadata.
To learn more about Azure Automation, see the Azure Automation documentation.
that were
installed directly from the PowerShell Gallery.
Similarly, to find out which scripts you have installed from the PowerShell Gallery, run
the
Get-InstalledScript cmdlet. This command lists all the scripts you have on your
system that were
installed directly from the PowerShell Gallery.
7 Note
The CDN for the PowerShell gallery is active for one name, psg-prod-
eastus.azureedge.net or
psg-prod-centralus.azureedge.net , at any given time. The
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:
PowerShell
[Net.ServicePointManager]::SecurityProtocol =
[Net.ServicePointManager]::SecurityProtocol -bor
[Net.SecurityProtocolType]::Tls12
Related links
Find-DscResource
Find-Module
Find-Script
Get-InstalledModule
Get-InstalledScript
Install-Module
Install-Script
Publish-Module
Publish-Script
Register-PSRepository
Save-Module
Save-Script
Update-Module
Update-Script
Frequently asked questions about
the PowerShell Gallery
FAQ
You do not need to register or sign in to the Gallery to install or save packages.
The specified API key is invalid. Ensure that you have specified the valid API key
from your account. To get your API key, view your profile page.
The specified package name is not owned by you. If you have confirmed that
your API key is correct, then there may already exist a package with the same name
as the one you are trying to use. The package may have been unlisted by the
owner, in which case it will not appear in any search results. To determine if a
package with the same name already exists, open a browser and navigate to the
package's details page:
https://www.powershellgallery.com/packages/<packageName> . For example,
Version
Description
Author
A URI to the license terms of the module, either as part of the PrivateData section
of the manifest, or in the LicenseUri parameter of the Publish-Module cmdlet.
To update the module manifest file fields, use the Update-ModuleManifest cmdlet.
Version
Description
Author
A URI to the license terms of the script, either as part of the PSScriptInfo section of
the script, or in the LicenseUri parameter of the Publish-Script cmdlet.
How do I search?
Type what you are looking for in the text box. For example, if you want to find modules
that are related to Azure SQL, just type "azure sql". Our search engine will look for those
keywords in all published packages, including titles, descriptions and across metadata.
Then, based on a weighted quality score, it will display the closest matches. You can also
search by specific field using field:"value" syntax in the search query for the following
fields:
Tags
Functions
Cmdlets
DscResources
PowerShellVersion
So, for example, when you search for PowerShellVersion:"2.0" only results that are
compatible with PowerShellVersion 2.0 (based on their module/script manifest) will be
displayed.
How do I create a correctly-formatted
script file?
The easiest way to create a properly-formatted script file is to run the New-ScriptFileInfo
cmdlet. In PowerShell 5.0, New-ScriptFileInfo generates a correctly-formatted script file
with blank fields for useful metadata like ProjectUri, LicenseUri, and Tags. Simply fill in
the blanks, or use the generated script file as an example of correct formatting.
To verify that all required metadata fields have been properly filled, use the Test-
ScriptFileInfo cmdlet.
Here is one way to think about it: the folder that encapsulates the module is the module
folder. The module folder can contain a module manifest (.psd1) that describes the
contents of the folder. The files that actually do the work are the script module files
(.psm1) and the binary module files (.dll). DSC resources are located in a specific sub-
folder, and are implemented as script module files or binary module files.
All of the modules in the Gallery contain module manifests, and most of these modules
contain script module files or binary module files. The term module can be confusing
because of these different meanings. Unless explicitly stated otherwise, all uses of the
word module on this page refer to the module folder containing these files.
You can use PowerShellGet against any valid NuGet repository or file share. You simply
need to add the repository by running the Register-PSRepository cmdlet.
Windows 10
Windows 8.1 Pro
Windows 8.1 Enterprise
Windows 7 SP1
Windows Server 2016
Windows Server 2012 R2
Windows Server 2008 R2 SP1
PowerShellGet also requires .NET Framework 4.5 or above. For more information, see
Install the .NET Framework for developers.
Search by Keywords
Syntax
Search attempts to find relevant documents containing all 3 keywords, and return
matching documents.
Entering a phrase between quotation marks ("") change the search to look for the
particular phrase
instead of separate keywords. Matching documents should usually
contain the exact phrase "azure
sql", including variations on capitalization e.g. "Azure
SQL", and also usually contain the word
'deployment'.
Filtering on fields
You can search for a specific package ID (or 'Id' or 'id'), or certain other fields by
prefixing
search terms with the field name.
Currently the searchable fields are 'Id', 'Version', 'Tags', 'Author', 'Owner', 'Functions',
'Cmdlets', 'DscResources' and 'PowerShellVersion'.
Examples
Syntax
ID:PSReadline
Syntax
Id:"AzureRM.Profile"
The 'Id' filter is a substring match, so if you search for the following:
Syntax
Id:"azure"
Syntax
id:azure tags:intellisense
Syntax
id:"azure.storage"
Syntax
Tags:DSC
Syntax
Functions:Get-TreeSize
Syntax
Cmdlets:Get-AzureRmEnvironment
Syntax
DscResources:xArchive
Syntax
PowerShellVersion:2.0
Finally, if you use a field we don't support, such as 'commands', we'll just ignore it and
search
all the fields. So the following query
Syntax
commands:blobs storage
Syntax
blobs storage
Starting with version 5.1, PowerShell is available in different editions which denote
varying
feature sets and platform compatibilities.
Desktop Edition: Built on .NET Framework and provides compatibility with scripts
and modules
targeting versions of PowerShell running on full footprint editions of
Windows such as Server Core
and Windows Desktop.
Core Edition: Built on .NET Core and provides compatibility with scripts and
modules
targeting versions of PowerShell running on reduced footprint editions of
Windows such as Nano
Server and Windows IoT.
Tags: "Windows"
Tags: "Linux"
Tags: "MacOS"
You can specify these tags on Find-Module (and other cmdlets in the PowerShellGet
module), like
this:
PowerShell
For example, if you are looking for a package that runs on both Windows and Linux
machines, use
the search tags:
To search using PowerShell, you can use the Find-Module (and the other cmdlets in the
PowerShellGet module), like this:
PowerShell
There are several ways to filter, sort, and search the packages. To see more details about
a
particular package, click the package.
Filter By
The drop-down under "Filter By" allows users to filter the results by:
Include Prerelease
Stable Only
The checkboxes under the drop-down allow users to filter the results by:
Package Types
Module
Script
Categories
Cmdlet
DSC Resource
Function
Role Capability
Workflow
To see only modules in the PowerShell Gallery, check Module in the Package Types.
Similarly, to see
only scripts in the PowerShell Gallery, check Script in the Package Types.
7 Note
Filters are inclusive. Example: A package containing both cmdlets and functions will
appear if
either Cmdlet or Function (or both) are checked. If neither are selected,
the package will not
appear. Similarly, if all categories are selected, only packages
containing one of those
categories will appear. Packages that do not belong to
any of those categories will not
appear.
Sort By
The Sort By drop-down allows users to sort the results by:
Search Box
The Search Box allows users to search the packages on keywords.
For more information,
see Gallery Search Syntax.
Creating and publishing an item
Article • 04/17/2023
The PowerShell Gallery is the place to publish and share stable PowerShell modules,
scripts, and
Desired State Configuration (DSC) resources with the broader PowerShell
user community.
This article covers the mechanics and important steps for preparing a script or module,
and
publishing it to the PowerShell Gallery. We strongly encourage that you review the
Publishing Guidelines to understand how to ensure that
the items you publish will be
more widely accepted by PowerShell Gallery users.
Have a PowerShell Gallery account, and the API Key associated with it
Ensure Required Metadata is in your item
Use the pre-validation tools to ensure your item is ready to publish
Publish the item to the PowerShell Gallery using the Publish-Module and Publish-
Script commands
Respond to questions or concerns about your item
The PowerShell Gallery accepts PowerShell modules and PowerShell scripts. When we
refer to scripts,
we mean a PowerShell script that is a single file, and not part of a larger
module.
Once you have created an account, you can get the API Key needed to publish an item.
After you sign
in with the account, your username will be displayed at the top of the
PowerShell Gallery pages
instead of Register. Clicking on your username will take you to
the My Account page, where you will
find the API Key.
) Important
The API Key must be treated as securely as your login and password. With this key
you, or anyone
else, can update any item you own in the PowerShell Gallery. We
recommend updating the key
regularly, which can be done using Reset Key on your
My Account page.
Required Metadata for Items Published to the
PowerShell Gallery
The PowerShell Gallery provides information to gallery users drawn from metadata fields
that are
included in the script or module manifest. Creating or modifying items for
publication to the
PowerShell Gallery has a small set of requirements for information
supplied in the item manifest. We
strongly encourage that you review the Item
Metadata section of the
Publishing Guidelines to learn how to provide the best
information to users with your items.
Both manifests have two sections that are important for publishing, the Primary Key
Data and PSData
area of PrivateData. The primary key data in a PowerShell module
manifest is everything outside of
the PrivateData section. The set of primary keys is tied
to the version of PowerShell in use, and
undefined are not supported. PrivateData
supports adding new keys, so the elements specific to the
PowerShell Gallery are in
PSData.
Manifest elements that are most important to fill in for item you publish to the
PowerShell Gallery
are:
Script or Module Name - Those are drawn from the names of the .PS1 for a script,
or the .PSD1 for
a module.
Version - this is a required primary key, format should follow SemVer guidelines.
See Best
Practices for details.
Author - this is a required primary key, and contains the name to be associated
with the item. See
Authors and Owners below.
Description - this is a required primary key, used to briefly explain what this item
does and any
requirements for using it
ProjectURI - this is a strongly recommended URI field in PSData that provides a link
to a GitHub
repo or similar location where you do development on the item
Tags - it is a strong recommendation to tag your package based on its
compatibility with
PSEditions and platforms. For details, see the
Publishing
Guidelines.
Authors and Owners of PowerShell Gallery items are related concepts, but do not always
match. Item
Owners are users with PowerShell Gallery accounts that have permission to
maintain the item. There
may be many Owners who can update any item. The Owner is
only available from the PowerShell Gallery,
and is lost if the item is copied from one
system to another. Author is a string that is built into
the manifest data, so it is always
part of the item. The recommendations for items from Microsoft
products are:
Have multiple owners, with at least one being the name of the team that produces
the item
Have the Author be a well-known team name (such as Azure SDK Team), or
Microsoft Corporation
If the manifest information in your item cannot be read by the PowerShell Gallery
infrastructure,
you will not be able to publish.
Test-ModuleManifest will catch
common
problems that would cause the module to not be usable when it is installed. It must be
run
for every module prior to publishing it to the PowerShell Gallery.
Publishing Items
You must use the Publish-Script or
Publish-Module to publish items to the PowerShell
Gallery. These commands both require:
The path to the item you will publish. For a module, use the folder named for your
module. If you
specify a folder that contains multiple versions of the same module,
you must specify
RequiredVersion.
A Nuget API key. This is the API key found in the My Account page on the
PowerShell Gallery.
Most of the other options in the command line should be in the manifest data for the
item you are
publishing, so you should not need to specify them in the command.
To avoid errors, it is strongly recommended that you try the commands using -WhatIf -
Verbose,
before publishing. This will save considerable time, since every time you
publish to the PowerShell
Gallery, you must update the version number in the manifest
section of the item.
Review the output carefully, and if you see no errors or warnings, repeat the command
without
-WhatIf.
All items that are published to the PowerShell Gallery will be scanned for viruses, and
will be
analyzed using the PowerShell Script Analyzer. Any issues that arise at that time
will be sent back
to the publisher for resolution.
Once you have published an item to the PowerShell Gallery, you will need to watch for
feedback on
your item.
Ensure you monitor the email address associated with the account used to publish.
Users, and the
PowerShell Gallery Operations team will provide feedback via that
account, including issues from
the PSSA or antivirus scans. If the email account is
invalid, or if serious issues are reported to
the account and left unresolved for a
long time, items can be considered abandoned and will be
removed from the
PowerShell Gallery as described in our
Terms of Use .
Creating a PowerShell Gallery account
Article • 08/15/2023
You must create a PowerShell Gallery account before publishing anything to the
PowerShell Gallery. PowerShell Gallery accounts must be linked to an email-enabled
login account. This account can be an Microsoft Entra ID account or a Microsoft ID, like
an email account from outlook.com or hotmail.com .
To use an Azure Active Directory account, select Work or School Account, and sign in
with your account. To use a Microsoft ID, choose Personal Account and sign in.
Next, you are prompted to create a username for the PowerShell Gallery. Review the
Terms of Use and Privacy Policy, enter a username, and then click Register.
7 Note
The account name can't be changed once it's created. For more information, see
Managing Package Owners.
Organizations that publish to the PowerShell Gallery often create a unique external
account for that purpose. We recommend you use email forwarding to forward
notifications to an address within your organization.
When multiple owners are associated with a package, all PowerShell Gallery notifications
are sent to all owners. For more information, see Managing Package Owners.
Unlisting Packages
Article • 04/17/2023
The PowerShell Gallery does not support users permanently deleting their packages.
This enables
others to take dependencies on your packages without worrying about
possible breaks in the future.
For example, if the Pester module depends on the Azure
module and the Azure module is removed from
the gallery, then users can no longer
use the Pester module.
Unlisting a package such as a module or script in the PowerShell Gallery removes it from
the
Packages tab. In addition, unlisted packages will not be discoverable using the
search bar. The only
way to download an unlisted package is to specify the exact name
and version of the package. Because
of this, the unlisting of a package will not break
other modules or scripts that depend on it.
To unlist your package, visit the package details page and select 'Delete Module'.
Uncheck the
'Listed' checkbox, and select 'Save'.
To submit a Delete Package Request to the PowerShell Gallery Administrators, visit your
package's
detail page and select Contact Support.
Deleting Packages
Article • 04/17/2023
The PowerShell Gallery does not support permanent deletion of packages, because that
would break
anyone who is depending on it remaining available.
Instead, the PowerShell Gallery supports a way to 'unlist' a package, which can be done
in the
package management page on the web site. When a package is unlisted, it no
longer shows up in search
and in any package listing, both on the PowerShell Gallery
and using PowerShellGet commands.
However, it remains downloadable by specifying
its exact version, which is what allows the automated
scripts to continue working.
If you run into an exceptional situation where you think one of your packages must be
deleted, this
can be handled manually by the PowerShell Gallery team. For example, if
there is a copyright
infringement issue, or potentially harmful content, that could be a
valid reason to delete it. You
should submit a support request through PowerShell
Gallery in
that case.
Managing package owners
Article • 04/17/2023
All package owners are peers. This means any package owner can publish a new version
of an package.
It also means that any package owner can remove any other package
owner. No owner has more authority
than other owners.
Adding Owners
Once a package has been published to the PowerShell Gallery, it's easy to invite
additional users to
become owners of a package.
7 Note
Until the new owner confirms ownership, they will not be listed as an owner of a
package. When
viewing the Manage Owners page, you will see a "pending
approval" entry in the current owners.
That invitation can be removed; just as other
owners can be removed. This process of invitations
prevents users from falsely
adding other users as owners of their packages.
The "Authors" metadata is purely freeform text; only "Owners" are controlled.
Removing Owners
When a package has multiple owners and one needs to be removed, the process is
simple:
1. The current owner invites the new user to become a co-owner and the new user
accepts the invite;
2. The new user removes the old user from the list of owners.
This request has come in under a couple forms but the process works the same.
Orphaned Packages
One last scenario has occurred, but not many times. Packages have become orphans
and the only
package owner account cannot be used to add new owners. Here are some
examples of this scenario:
The owner's account is associated with an email address that no longer exists and
the user has
forgotten their password
The registered owner has left the company that produces the package and cannot
be reached to
update the package ownership
Due to a bug that has only affected a handful of packages, the package is
somehow ownerless on the
gallery
The PowerShell Gallery Administrators can access the 'Manage Owners' link for any
package. If you
are the rightful owner of a package and cannot reach the current owner
to gain ownership
permissions, then use the 'Report Abuse' link on the gallery to reach
the PowerShell Gallery
Administrators. We will then follow a process to verify your
ownership of the package. If we
determine you should be an owner of the package, we
will use the 'Manage Owners' link for the
package ourselves and send you the invite to
become an owner. We will only do this after verifying
that you should be an owner and
the process for this varies by circumstances. Often times, we will
use the package's
Project URL to find a way to contact the project owner, but we may also use
Twitter,
Email, or other means for contacting the project owner.
FileList feature in the Gallery
Article • 04/17/2023
You are able to view the contents in all packages published in the gallery.
This feature includes two parts: listing the files within the package, and displaying file
contents
for supported file types. Currently we support displaying the contents of the
following file
extensions: .ps1, .psm1, .psd1, .ps1xml, .xml and .txt. We will be supporting
more file extensions
in the next releases.
Each supported file type is displayed as a hyperlink, and clicking it will take you to a new
page
with file contents displayed in PowerShell syntax highlighting. Clicking on the title
or the version
of the package, which is displayed at the top of the screen, will bring you
back to package detail
page.
Deploy to Azure Automation
Article • 04/17/2023
The Deploy to Azure Automation button on the package details page will deploy the
package from
the PowerShell Gallery to Azure Automation.
When clicked, it will redirect you to the Azure Management Portal, where you sign in
using your
Azure account credentials. If the package includes dependencies, all the
dependencies will be
deployed to Azure Automation as well.
2 Warning
If the same package and version already exists in your Automation account,
deploying it again from
the PowerShell Gallery overwrites the package in your
Automation account.
If you deploy a module, it will appear in the Modules section of Azure Automation. If
you deploy a
script, it will appear in the Runbooks section of Azure Automation.
) Important
The Deploy to Azure Automation feature does not work for sovereign (air-gapped)
clouds like
Azure Government, Azure Germany, or
Azure China 21Vianet.
The PowerShell Gallery supports downloading a package from the website directly,
without using the
PowerShellGet cmdlets. You can download any package as a NuGet
package ( .nupkg ) file, which you
can then copy to an internal repository.
7 Note
A NuGet package is a ZIP archive with extra files containing information about the
contents of the
package. Some browsers, like Internet Explorer, automatically replace
the .nupkg file extension
with .zip . To expand the package, rename the .nupkg file to
.zip , if needed, then extract the
contents to a local folder.
A NuGet package file includes the following NuGet-specific elements that aren't part of
the
original packaged code:
A folder named _rels - contains a .rels file that lists the dependencies
A folder named package - contains the NuGet-specific data
A file named [Content_Types].xml - describes how extensions like PowerShellGet
work with NuGet
A file named <name>.nuspec - contains the bulk of the metadata
7 Note
These instructions DO NOT give the same result as running Install-Module . These
instructions
fulfill the minimum requirements. They aren't intended to be a
replacement for Install-Module .
Some steps performed by Install-Module aren't
included.
The easiest approach is to remove the NuGet-specific elements from the folder.
Removing the elements
leaves the PowerShell code created by the package author.
For
the list of NuGet-specific elements, see Using manual download to acquire a package.
1. Unblock the Internet-downloaded NuGet package ( .nupkg ) file, for example using
Unblock-File -Path C:\Downloads\module.nupkg cmdlet.
2. Extract the contents of the NuGet package to a local folder.
3. Delete the NuGet-specific elements from the folder.
4. Rename the folder. The default folder name is usually <name>.<version> . The
version can
include -prerelease if the module is tagged as a prerelease version.
Rename the folder to just
the module name. For example, azurerm.storage.5.0.4-
preview becomes azurerm.storage .
5. Copy the folder to one of the folders in the $env:PSModulePath value .
$env:PSModulePath is a
semicolon-delimited set of paths in which PowerShell
should look for modules.
) Important
The manual download doesn't include any dependencies required by the module. If
the package has
dependencies, they must be installed on the system for this
module to work correctly. The
PowerShell Gallery shows all dependencies required
by the package.
7 Note
These instructions DO NOT give the same result as running Install-Script . These
instructions
fulfill the minimum requirements. They aren't intended to be a
replacement for Install-Script .
The easiest approach is to extract the NuGet package, then use the script directly.
1. Unblock the Internet-downloaded NuGet package ( .nupkg ) file, for example using
Unblock-File -Path C:\Downloads\package.nupkg cmdlet.
For the list of NuGet-specific elements, see Using manual download to acquire a
package.
) Important
The manual download doesn't include any dependencies required by the module. If
the package has
dependencies, they must be installed on the system for this
module to work correctly. The
PowerShell Gallery shows all dependencies required
by the package.
Require license acceptance
Article • 04/17/2023
Require License Acceptance text shows up on item details page for modules that require
license
acceptance. License for module can be viewed by clicking on View License.txt
link.
Users will be prompted to accept the license when installing, saving or updating the
module through
PowerShellGet or when deploying to Azure Automation.
To contact owner of a particular package, navigate to the package detail page. There is a
contact
Owners link in the left menu bar. Clicking on the link will take you to a new
page. You can send a
message from here.
PowerShell Gallery Account Settings
Article • 04/17/2023
Your PowerShell Gallery account is a publicly visible name that is linked to an identity.
That
identity is either a Microsoft ID, like user@hotmail.com or user@outlook.com , or an
Azure
Active Directory (AAD) account.
Email address
The email address is the destination for PowerShell Gallery notifications. It does not have
to
match the login account. You may use any email account you have access to. Your
email address is
never directly provided by the PowerShell Gallery to other users.
When you enter a new email address, the PowerShell Gallery sends a verification mail to
that
address. The verification mail contains a link back to the PowerShell Gallery to
complete the
change process. Until you complete the verification process, all
notifications are sent to the
previous address.
Email notifications
PowerShell Gallery provides the following notification options:
Security notifications
Account management notifications from PowerShell Gallery administrators
Notifications about the tests run by the PowerShell Gallery for submissions you
have made
1. Click on Change Account. A pop-up window explains that changing the login
account applies to
all uses of that account in the PowerShell Gallery. Review the
information, then click OK to
continue.
4. Enter the password of the new account. After entering the password, you are
returned to the
Account Settings page showing you that the login account has
been updated.
Enable Two-Factor Authentication (2FA)
Two-factor authentication is recommended for all users who publish manually to the
PowerShell
Gallery. To enable two-factor authentication, the login account must have at
least two forms of
authentication registered. One is a password and the other forms can
be:
Once 2FA is enabled, you are required to authenticate using the configured forms of
authentication
every time you sign in to the PowerShell Gallery.
) Important
Enabling two-factor authentication for the PowerShell Gallery site does not require
you to enable
2FA for all uses of your login account. For more information, see
About two-step verification .
The PowerShell Gallery supports creating multiple API keys to support a range of
publishing
requirements. An API key can apply to one or more packages, grants specific
privileges, and has an
expiration date.
) Important
Users who published to the PowerShell Gallery prior to the introduction of scoped
API keys will
have a "Full access API key". The full access keys do not have the
security improvements built
into scoped API keys. The full access keys never expires
and apply to everything owned by the
user. If you delete this key, it cannot be
recreated.
The following image shows the options available when creating a scoped API key.
In this example, we created an API key named AzureRMDataFactory. This key value can
be used to
push packages with names that begin with 'AzureRM.DataFactory' and is
valid for 365 days. This is a
typical scenario when different teams within the same
organization work on different packages. The
members of the team have a key that
grants them privileges for the specific package they work on.
The expiration value
prevents the use of stale or forgotten keys.
) Important
You can only copy the API key value immediately after creating or refreshing it. It
will not be
displayed, and will not be accessible again after the page is refreshed. If
you lose the key
value, you must use Regenerate, and copy the key after it is
regenerated.
Every new key has an expiration. The expiration value is measured in days. The possible
values for expiration are:
1 day
90 days
180 days
270 days
365 days (default)
These settings cannot be changed once the key is created. You cannot create a new key
that never
expires.
Clicking Regenerate creates a new key value. Just like when you initially created the key,
you
must Copy the key value immediately after updating it. The Copy option is not
available
once you leave this page.
Key expiration
Ten days before the expiration, the PowerShell Gallery sends a warning email the
account holder of
the API key. After expiration, the key is unusable. A warning message
is displayed at the top of
the API key management page showing which keys are no
longer valid. You can generate a new key
value.
Working with Private PowerShellGet
Repositories
Article • 08/04/2023
The PowerShellGet module support repositories other than the PowerShell Gallery.
These cmdlets enable the following scenarios:
This article describes how to set up a local PowerShell repository. The article also covers
the OfflinePowerShellGetDeploy module available from the PowerShell Gallery. This
module contains cmdlets to install the latest version of PowerShellGet into your local
repository.
NuGet Server
Advantages Disadvantages
Mimics PowerShellGallery functionality Multi-tier app requires operations planning & support
NuGet integrates with Visual Studio, Authentication model and NuGet accounts
other tools management needed
NuGet supports metadata in .Nupkg Publishing requires API Key management &
packages maintenance
File Share
Advantages Disadvantages
Easy to set up, back up, and maintain No UI beyond basic file share
Simple security model - user permissions on Limited security and no recording of who
the share updates what
PowerShellGet works with either type and supports locating versions and dependency
installation. However, some features that work for the PowerShell Gallery aren't available
for base NuGet servers or file shares. There is no differentiation of scripts, modules, DSC
resources, or role capabilities.
NuGet.Server
Follow the steps up to the point of adding packages. The steps for publishing a package
are covered later in this article.
For a file share-based repository, make sure that your users have permissions to access
the file share.
PowerShell
Take note of the difference between how the two commands handle
ScriptSourceLocation. For a file share-based repositories, the SourceLocation and
ScriptSourceLocation must match. For a web-based repository, they must be different,
so in this example a trailing "/" is added to the SourceLocation.
If you want the newly created PSRepository to be the default repository, you must
unregister all other PSRepositories. For example:
PowerShell
7 Note
The repository name 'PSGallery' is reserved for use by the PowerShell Gallery. You
can unregister PSGallery, but you can't reuse the name PSGallery for any other
repository.
PowerShell
Register-PSRepository -Default
7 Note
You must create an account in the NuGet server, then sign in to generate and save
the API key. For a file share, use any non-blank string for the NuGetApiKey value.
Examples:
PowerShell
) Important
To ensure security, API keys shouldn't be hard-coded in scripts. Use a secure key
management system. When executing a command manually, API keys shouldn't be
passed as plain-text to avoid it being logged, the Read-Host cmdlet can be used to
safely pass the value of the API key.
PowerShell
# Publish to a file share repo - the NuGet API key must be a non-blank
string
$publishModuleSplat = @{
Path = 'c:\projects\MyModule'
Repository = 'LocalPsRepo'
NuGetApiKey = 'AnyStringWillDo'
}
Publish-Module @publishModuleSplat
Example:
PowerShell
# Requires -RunAsAdministrator
#Download the OfflinePowerShellGetDeploy to a location that can be accessed
# by both the connected and disconnected systems.
Save-Module -Name OfflinePowerShellGetDeploy -Path 'F:\' -Repository
PSGallery
Import-Module F:\OfflinePowerShellGetDeploy
At this point, you must make the contents of F:\OfflinePowerShellGet available to your
disconnected systems. Run the Install-PowerShellGetOffline cmdlet to install
PowerShellGet on the disconnected system.
7 Note
It's important that you don't run PowerShellGet in the PowerShell session before
running these commands. Once PowerShellGet is loaded into the session, the
components can't be updated. If you do start PowerShellGet by mistake, exit and
restart PowerShell.
PowerShell
Import-Module F:\OfflinePowerShellGetDeploy
Install-PowerShellGetOffline -LocalFolder 'F:\OfflinePowerShellGet'
After running these commands, you are ready to publish PowerShellGet to your local
repository.
PowerShell
) Important
To ensure security, API keys shouldn't be hard-coded in scripts. Use a secure key
management system. When executing a command manually, API keys shouldn't be
passed as plain-text to avoid it being logged, the Read-Host cmdlet can be used to
safely pass the value of the API key.
PowerShell
# Publish to a file share repo - the NuGet API key must be a non-blank
string
$publishModuleSplat = @{
Path = 'F:\OfflinePowerShellGet'
Repository = 'LocalPsRepo'
NuGetApiKey = 'AnyStringWillDo'
}
Publish-Module @publishModuleSplat
This article describes recommended steps used by Microsoft teams to ensure the
packages published to
the PowerShell Gallery will be widely adopted and provide high
value to users, based on how the
PowerShell Gallery handles manifest data and on
feedback from large numbers of PowerShell Gallery
users. Packages that are published
following these guidelines will be more likely to be installed,
trusted, and attract more
users.
Included below are guidelines for what makes a good PowerShell Gallery package, what
optional
Manifest settings are most important, improving your code with feedback from
initial reviewers and
Powershell Script Analyzer , versioning your module,
documentation, tests and examples for how to use what you have shared. Much of this
documentation
follows the guidelines for publishing
High Quality DSC Resource
Modules .
Feedback on these guidelines is welcomed. If you do have feedback, please open issues
in our
GitHub documentation repository .
Use PSScriptAnalyzer
Include documentation and examples
Be responsive to feedback
Provide modules rather than scripts
Provide links to a project site
Tag your package with the compatible PSEdition(s) and platforms
Include tests with your modules
Include and/or link to license terms
Sign your code
Follow SemVer guidelines for versioning
Use common tags, as documented in Common PowerShell Gallery tags
Test publishing using a local repository
Use PowerShellGet to publish
Use PSScriptAnalyzer
PSScriptAnalyzer is a free static
code analysis tool that works on PowerShell code.
PSScriptAnalyzer will identify the most common
issues seen in PowerShell code, and
often a recommendation for how to fix the issue. The tool is
easy to use, and categorizes
the issues as Errors (severe, must be addressed), Warning (need to be
reviewed and
should be addressed), and Information (worth checking out for best practices). All
packages published to the PowerShell Gallery will be scanned using PSScriptAnalyzer,
and any
errors will be reported back to the owner and must be addressed.
Users who download packages from the PowerShell Gallery are strongly encouraged to
run
PSScriptAnalyzer and evaluate all Errors and Warnings. Users are very likely to
contact package
owners if they see that there's an error reported by PSScriptAnalyzer. If
there's a compelling
reason for your package to keep code that is flagged as an error,
add that information to your
documentation to avoid having to answer the same
question many times.
Examples show users how the package is intended to be used. Many developers will say
that they look
at examples before documentation to understand how to use something.
The best types of examples show
basic use, plus a simulated realistic use case, and the
code is well-commented. Examples for modules
published to the PowerShell Gallery
should be in an Examples folder under the module root.
description at the top of each file that documents what is being demonstrated.
Manage Dependencies
It's important to specify modules that your module is dependent on in the Module
Manifest. This
allows the end user to not have to worry about installing the proper
versions of modules that yours
take a dependency on. To specify dependent modules,
you should use the required module field in the
module manifest. This will load any
listed modules into the global environment prior to importing
your module unless
they've already been loaded. For example, some modules may already be loaded by a
different module. It's also possible to specify a specific version to load using the
RequiredVersion field rather than the ModuleVersion field. When using ModuleVersion,
it
will load the newest version available with a minimum of the version specified. When
not using the
RequiredVersion field, to specify a specific version it's important to
monitor version updates
to the required module. It's especially important to be aware of
any breaking changes that could
affect the user experience with your module.
PowerShell
Respond to feedback
Package owners who respond properly to feedback are highly valued by the community.
Users who
provide constructive feedback are important to respond to, as they're
interested enough in the
package to try to help improve it.
Contact Owner: This allows a user to send an email to the package owner. As a
package owner, is
important to monitor the email address used with the
PowerShell Gallery packages, and respond to
issues that are raised. The one
disadvantage to this method is that only the user and owner will
ever see the
communication, so the owner may have to answer the same question many times.
Owners who respond to feedback constructively are appreciated by the community. Use
the opportunity
in the report to request more information. If needed, provide a
workaround, or identify if an update
fixes a problem.
PowerShell Modules have a folder structure that allows multiple folders and files to be
included
with the package. The module structure enables including the other packages
we list as best
practices: cmdlet help, documentation, examples, and tests. The biggest
disadvantage is that a
script inside a module must be exposed and used as a function.
For information on how to create a
module, see
Writing a Windows PowerShell Module.
There are situations where a script provides a better experience for the user, particularly
with DSC
configurations. The best practice for DSC configurations is to publish the
configuration as a script
with an accompanying module that contains the docs,
examples, and tests. The script lists the
accompanying module using RequiredModules =
@(Name of the Module) . This approach can be used with
any script.
Standalone scripts that follow the other best practices provide real value to other users.
Providing
comment-based documentation and a link to a Project Site are highly
recommended when publishing a
script to the PowerShell Gallery.
Provide a link to a project site
A Project Site is where a publisher can interact directly with the users of their PowerShell
Gallery
packages. Users prefer packages that provide this, as it allows them to get
information about the
package more easily. Many packages in the PowerShell Gallery
are developed in GitHub, others are
provided by organizations with a dedicated web
presence. Each of these can be considered a project
site.
Adding a link is done by including ProjectURI in the PSData section of the manifest as
follows:
ProjectUri = 'https://github.com/powershell/powershell'
When a ProjectURI is provided, the PowerShell Gallery will include a link to the Project
Site on the
left side of the package page.
By tagging your package with the compatible platform(s) it will be included in the
Gallery search
filters on the left pane of the search results. If you host your package on
GitHub, when you tag
your package, you can also take advantage of our
PowerShell
Gallery compatibility shields
platform windows | linux | macos .
Include tests
Including tests with open-source code is important to users, as it gives them assurance
about what
you validate, and provides information on how your code works. It also
allows users to ensure they
don't break your original functionality if they modify your
code to fit their environment.
It's strongly recommended that tests be written to take advantage of the Pester test
framework,
which has been designed specifically for PowerShell. Pester is available in
GitHub , the
PowerShell Gallery , and ships in Windows 10,
Windows Server 2016,
WMF 5.0 and WMF 5.1.
PowerShell
PrivateData = @{
PSData = @{
Tags = @('.net','acl','active-directory')
LicenseUri = 'http://www.apache.org/licenses/LICENSE-2.0'
Catalog signing modules is a feature added to PowerShell in version 5.1. How to sign a
module is
covered in the
Catalog Cmdlets article.
In overview, catalog signing is done by
creating a catalog file, which contains a hash value for
every file in the module, and then
signing that file.
One additional point about test publishing: any package you publish to the PowerShell
Gallery can't
be deleted without help from the operations team, who will confirm that
nothing is dependent upon
the package you wish to publish. For that reason, we don't
support the PowerShell Gallery as a
testing target, and will contact any publisher who
does so.
If there's a reason that you can't use Publish-Module or Publish-Script , please let us
know.
File an issue in the PowerShellGet GitHub repo, and provide the details that cause
you to choose
NuGet or PackageManagement.
Recommended workflow
The most successful approach we have found for packages published to the PowerShell
Gallery is this:
Continue to gather feedback and iterate on your code based on user input.
Package metadata values that impact
the PowerShell Gallery UI
Article • 04/17/2023
This article explains how the metadata in your packages is used by the PowerShell
Gallery. For
modules, the metadata is stored in the module manifest. For scripts, the
metadata is store using
comment-based keywords. The following cmdlets are use to
create or update this metadata:
New-ModuleManifest
Update-ModuleManifest
New-ScriptFileInfo
Update-ScriptFileInfo
Version - The version displayed is the version string in the metadata, and a
prerelease label
if is specified. The specified prerelease string is appended to the
ModuleVersion. For
information about prerelease strings in modules, see
Prerelease Module Versions.
Require license acceptance - A module can require that the user accept a license,
by setting
RequireLicenseAcceptance = $true , supplying a LicenseURI, and
providing a license.txt file
in the root of the module folder. For more
information, see Require License Acceptance.
Release notes - This information is comes from the ReleaseNotes section, under
PSData\PrivateData .
Owners - Owners are the list of users in the PowerShell Gallery who can update a
package. The
owner list isn't included in the package manifest. Additional
documentation describes how to
manage item owners.
Author - This is included in the module manifest as the Author. The Author field is
often
used to specify a company or organization associated with a package.
FileList - The file list is created when the package is published to the PowerShell
Gallery.
It's not controllable by the manifest information. The PowerShell Gallery
creates .nuspec file
that appears in the file list of each package. This file isn't
installed with the package on a
system. This is the NuGet package manifest for the
package and can be ignored.
Tags - Tags are included under PrivateData\PSData in the module manifest. Tags
have
specific requirements and meanings that are described in the Tag Details
section.
Role capabilities - Roles are listed when the module has one or more role
capability ( .psrc )
files. These files are used by JEA. For more information, see role
capabilities.
PowerShell Editions - For modules designed for PowerShell 5.0 and lower, this is
controlled
using Tags. For Desktop, use the tag PSEdition_Desktop, and for core,
use the tag
PSEdition_Core. For modules designed for PowerShell 5.1 and higher,
there is a
CompatiblePSEditions key in the manifest. For more information, see
PSEdition support for modules.
Version History - Shows a list of versions of the module that have been published
to the
Gallery. Packages hidden using the Delete feature aren't displayed in the
version history
unless you are a package owner.
Project Site - The project site is provided for modules in the PrivateData\PSData
section of
the module manifest by specifying a ProjectURI.
) Important
If a license isn't provided via the LicenseURI or within the package then the
Terms of Use
for the PowerShell Gallery apply to the package. For more
information, see the
Terms of Use .
Title - This is the name of the package that is published to the Gallery
Version - The version displayed is the version string in the metadata, and a
prerelease label
if is specified. The value comes from the .VERSION keyword in the
metadata comment block. When
publishing prerelease script, append the
prerelease string to the version. For information about
specifying prerelease strings
in modules, see Prerelease versions of scripts.
Release notes - This information comes from the .RELEASENOTES keyword in the
comment-based
metadata of a script file.
Owners - Owners are the list of users in the PowerShell Gallery who can update a
package. The
owner list isn't included in the package manifest. For more
information, see
manage item owners.
Author - This information comes from the .AUTHOR keyword in the comment-
based metadata of a
script file. The Author field is often used to specify a company
or organization associated with a
package.
FileList - The file list is created when the package is published to the PowerShell
Gallery.
It's not controllable by the manifest information. The PowerShell Gallery
creates .nuspec file
that appears in the file list of each package. This file isn't
installed with the package on a
system. This is the NuGet package manifest for the
package and can be ignored.
Tags - *This information comes from the .TAGS keyword in the comment-based
metadata of a
script file. Tags have specific requirements and meanings that are
described in the
Tag Details section.
PowerShell Editions - For modules designed for PowerShell 5.0 and lower, this is
controlled
using Tags. For Desktop, use the tag PSEdition_Desktop, and for core,
use the tag
PSEdition_Core. For modules designed for PowerShell 5.1 and higher,
there is a
CompatiblePSEditions key in the manifest. For more information, see
PSEdition support for modules.
Version History - Shows a list of versions of the module that have been published
to the
Gallery. Packages hidden using the Delete feature aren't displayed in the
version history
unless you are a package owner.
Project Site - This information comes from the .PROJECTURI keyword in the
comment-based
metadata of a script file.
License - This information comes from the .LICENSEURI keyword in the comment-
based metadata
of a script file.
) Important
If a license isn't provided via the .LICENSEURI or within the package then the
Terms of Use
for the PowerShell Gallery apply to the package. For more
information, see the
Terms of Use .
Icon - This information comes from the .ICONURI keyword in the comment-based
metadata of a
script file. The URI should point to an 85x85 image with
transparency background. The URI must
be a direct link to the image file and must
not go to a web page or a file in the PowerShell
Gallery package.
Title
Description
Summary
Icon URL
Project home page URL
Authors
Copyright
Tags
Release notes
Require license
You should only edit this information in the Gallery to correct what's displayed for an
older
version of a module. Users that download the package will see the metadata
doesn't match the
PowerShell Gallery. Any time you change information in the Gallery,
you should publish a new version
of the package with the same changes.
Tag details
Tags are simple strings consumers use to find packages. Tags are most valuable when
they're used
consistently across related packages. Using variations of the same word, for
example database and
databases or test and testing, provides little benefit. Tags are
single-word case-insensitive
strings and can't include blanks. If there is a phrase that
you believe users will search for, add
that to the package description so that it can be
found in the search results. Use Pascal casing,
hyphens, underscores, or periods to
improve readability. Be cautious about creating long, complex,
and unusual tags that are
easily misspelled.
The PowerShell Gallery and PowerShellGet cmdlets have special meanings for the
PSEdition_Desktop
and PSEdition_Core tags. See the preceding discussion of
PowerShell Editions.
As noted previously, tags provide the most value when they're specific, and used
consistently across
many packages. As a publisher trying to locate the best tags to use,
the easiest approach is to
search the PowerShell Gallery for tags you are considering.
Ideally, the packages returned align
with your use of that keyword.
The following table shows some of the most commonly used tags. The preferred tag
should return the
best search results.
Appveyor
Automation
AWS
Azure
AzureAD
AzureAutomation
Backup
Build
ChatOps
Cloud
Color
Configuration
CrescendoBuilt This tag is added automatically by Crescendo when you export the
module
DBA
DevOps
DNS
Docker
Preferred tag Alternatives and notes
DSCResource
DSCResourceKit
Excel
Exchange
Firewall
GIT
GitHub
Gitlab
HTML
IaaS
IIS
Json
Linux
MacOS
Monitoring
MSI
Office365 Spelling out Office is preferable. O365 is less commonly used, although
shorter
PackageManagement
Pester
PoshBot
Preferred tag Alternatives and notes
ResourceManager "Arm" is used to describe group of processors, and shouldn't be used for
Azure Resource Manager
REST
SharePoint
SQL
SQLServer
Storage
VSTS
Windows
WinRM
WMI
Zip
Script with compatible PowerShell
editions
Article • 04/17/2023
Starting with version 5.1, PowerShell is available in different editions which denote
varying
feature sets and platform compatibility.
Desktop Edition: Built on .NET Framework and provides compatibility with scripts
and modules
targeting versions of PowerShell running on full footprint editions of
Windows such as Server
Core and Windows Desktop.
Core Edition: Built on .NET Core and provides compatibility with scripts and
modules
targeting versions of PowerShell running on reduced footprint editions of
Windows such as Nano
Server and Windows IoT.
PowerShell
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.14300.1000
PSEdition Desktop
CLRVersion 4.0.30319.42000
BuildVersion 10.0.14300.1000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Script authors can prevent a script from executing unless it is run on a compatible
edition of
PowerShell using the PSEdition parameter on a #requires statement.
PowerShell
Get-Content C:\script.ps1
C:\script.ps1
At line:1 char:1
+ C:\script.ps1
+ ~~~~~~~~~~~~~
+ FullyQualifiedErrorId : ScriptRequiresUnmatchedPSEdition
PowerShell Gallery users can find the list of scripts supported on a specific PowerShell
Edition.
Scripts without PSEdition_Desktop and PSEdition_Core tags are considered to
work fine on PowerShell
Desktop edition.
PowerShell
More details
Modules with PSEditions
PSEditions support on PowerShellGallery
Modules with compatible PowerShell
Editions
Article • 04/17/2023
Starting with version 5.1, PowerShell is available in different editions, which denote
varying
feature sets and platform compatibility.
7 Note
Once a module manifest is specified with the CompatiblePSEditions key or uses the
$PSEdition
variable, it can not be imported on PowerShell v4 or lower.
PowerShell
$ModuleInfo.CompatiblePSEditions
Output
Desktop
Core
PowerShell
$ModuleInfo | Get-Member CompatiblePSEditions
Output
TypeName: System.Management.Automation.PSModuleInfo
CompatiblePSEditions Property
System.Collections.Generic.IEnumerable[string] CompatiblePSEditions {get;}
When getting a list of available modules, you can filter the list by PowerShell edition.
PowerShell
Output
PowerShell
Output
Desktop
Core
PowerShell
A single module can work on both Desktop and Core editions, in that module author
has to add
required logic in either RootModule or in the module manifest using
$PSEdition variable. Modules
can have two sets of compiled DLLs targeting both
Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll
Microsoft.Windows.PowerShell.ScriptAnalyzer.dll
PSScriptAnalyzer.psd1
PSScriptAnalyzer.psm1
ScriptAnalyzer.format.ps1xml
ScriptAnalyzer.types.ps1xml
coreclr\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll
coreclr\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll
en-US\about_PSScriptAnalyzer.help.txt
en-US\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml
PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll
PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll
Settings\CmdletDesign.psd1
Settings\DSC.psd1
Settings\ScriptFunctions.psd1
Settings\ScriptingStyle.psd1
Settings\ScriptSecurity.psd1
PowerShell
@{
Author = 'Microsoft Corporation'
RootModule = 'PSScriptAnalyzer.psm1'
ModuleVersion = '1.6.1'
# ---
Below logic loads the required assemblies depending on the current edition or version.
PowerShell
Set-StrictMode -Version Latest
# Set up some helper variables to make it easier to work with the module
$PSModule = $ExecutionContext.SessionState.Module
$PSModuleRoot = $PSModule.ModuleBase
$binaryModuleRoot = $PSModuleRoot
if (($PSVersionTable.Keys -contains "PSEdition") -
and ($PSVersionTable.PSEdition -ne 'Desktop')) {
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'coreclr'
else
if ($PSVersionTable.PSVersion -lt [Version]'5.0')
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'PSv3'
}
$binaryModulePath = Join-Path -Path $binaryModuleRoot -
ChildPath 'Microsoft.Windows.PowerShell.ScriptAnalyzer.dll'
$binaryModule = Import-Module -Name $binaryModulePath -PassThru
# When the module is unloaded, remove the nested binary module that was
loaded with it
$PSModule.OnRemove = {
Remove-Module -ModuleInfo $binaryModule
PowerShell
@{
'coreclr\MyCoreClrRM.dll'
}
else # Desktop
'clr\MyFullClrRM.dll'
# Supported PSEditions
'coreclr\MyCoreClrNM1.dll',
'coreclr\MyCoreClrNM2.dll'
else # Desktop
'clr\MyFullClrNM1.dll',
'clr\MyFullClrNM2.dll'
Module contents
ModuleWithEditions\ModuleWithEditions.psd1
ModuleWithEditions\clr\MyFullClrNM1.dll
ModuleWithEditions\clr\MyFullClrNM2.dll
ModuleWithEditions\clr\MyFullClrRM.dll
ModuleWithEditions\coreclr\MyCoreClrNM1.dll
ModuleWithEditions\coreclr\MyCoreClrNM2.dll
ModuleWithEditions\coreclr\MyCoreClrRM.dll
More details
Scripts with PSEditions
about_PowerShell_Editions
Requiring license acceptance for scripts
Article • 04/17/2023
License Acceptance is not supported for scripts. However, the scenario where a script
depends on a
module that requires license acceptance is supported.
The PowerShellGet script commands support the parameter AcceptLicense that behaves
as though
user saw the license. If AcceptLicense is not specified the user is shown the
license.txt file
for dependent module and prompted to accept the license.
EXAMPLES
PowerShell
License Acceptance
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "N"):
More details
Require License Acceptance support for Modules
Require License Acceptance support on PowerShellGallery
Require License Acceptance on Deploy to Azure Automation
Modules Requiring License Acceptance
Article • 04/17/2023
SYNOPSIS
Legal departments for some module publishers require that customers must explicitly
accept the
license before installing their module from PowerShell Gallery. If a user
installs, updates, or
saves a module using PowerShellGet, whether directly or as a
dependency for another package, and
that module requires the user to agree to a
license, the user must indicate they accept the license
or the operation fails.
Impact on Install/Save/Update-Module
Install/Save/Update cmdlets support a new parameter AcceptLicense that behaves
as though
the user saw the license.
If RequiredLicenseAcceptance is True and AcceptLicense is not specified, the user
is shown
the license.txt , and prompted with: Do you accept these license terms
(Yes/No/YesToAll/NoToAll) .
If the license is accepted
Save-Module: the module is copied to the user's system
Install-Module: the module is copied to the user's system to the proper
folder (based on
scope)
Update-Module: the module is updated.
If the license is declined.
Operation is canceled.
All cmdlets check for the metadata (requireLicenseAcceptance and Format
Version) that says
a license acceptance is required
If format version of client is older than 2.0, operation fails and asks the user
to update the
client.
If module was published with format version older than 2.0,
requireLicenseAcceptance flag is
ignored.
Module Dependencies
During Install/Save/Update operation, if a dependent module(something else
depends on the module)
requires license acceptance, then the license acceptance
behavior (above) is required.
If the module version is already listed in the local catalog as being installed on the
system, we
would bypass the license checking.
During Install/Save/Update operation, if a dependent module requires a license,
and the license
acceptance does not occur, the operation fails and follows normal
processes for the package
failed to install/save/update.
Impact on -Force
Specifying –Force is NOT sufficient to accept a license. –AcceptLicense is required for
permission to install. If –Force is specified, RequiredLicenseAcceptance is True, and
–
AcceptLicense is NOT specified, the operation fails.
EXAMPLES
PSData = @{
RequireLicenseAcceptance = $true
This command updates the manifest file and sets the RequireLicenseAcceptance flag to
true.
Example 2: Install Module requiring license acceptance
PowerShell
Output
License Acceptance
License 2.0
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "N"):
This command shows the license from license.txt file and prompts the user to accept
the license.
Output
PackageManagement\Install-Package : License Acceptance is required for
module 'ModuleRequireLicenseAcceptance'. Please specify '-AcceptLicense' to
perform this operation.
At C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.1.3.3\PSModule.psm1:1837
char:21
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument:
(Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], E
xception
+ FullyQualifiedErrorId : ForceAcceptLicense,Install-
PackageUtility,Microsoft.PowerShell.PackageManagement.Cmdlets
.InstallPackage
PowerShell
Output
License Acceptance
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "N"):
PowerShell
Output
Output
License Acceptance
License 2.0
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "N"):
This command shows the license from license.txt file and prompts the user to accept
the license.
Output
License Acceptance
License 2.0
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "N"):
This command shows the license from license.txt file and prompts the user to accept
the license.
More details
Require License Acceptance for Scripts
Starting with version 1.6.0, PowerShellGet and the PowerShell Gallery provide support
for tagging
versions greater than 1.0.0 as a prerelease. Prior to this feature, prerelease
packages were limited
to having a version beginning with 0. The goal of these features
is to provide greater support for
SemVer v1.0.0 versioning convention without
breaking
backwards compatibility with PowerShell versions 3 and above, or existing
versions of
PowerShellGet. This topic focuses on the module-specific features. The
equivalent features for
scripts are in the Prerelease Versions of Scripts topic. Using these
features, publishers can identify a module or script as version 2.5.0-alpha, and later
release a
production-ready version 2.5.0 that supersedes the prerelease version.
Adding a Prerelease string to the PSData section of the module manifest identifies
the module as
a prerelease version. When the module is published to the
PowerShell Gallery, this data is
extracted from the manifest, and used to identify
prerelease packages.
Acquiring prerelease packages requires adding -AllowPrerelease flag to the
PowerShellGet commands
Find-Module , Install-Module , Update-Module , and Save-
Module . If the flag is not specified,
prerelease packages will not be shown.
These changes do not affect the module version support that is built into PowerShell,
and are
compatible with PowerShell 3.0, 4.0, and 5.
PowerShell
@{
ModuleVersion = '2.5.0'
#---
PrivateData = @{
PSData = @{
Prerelease = 'alpha'
Prerelease string may only be specified when the ModuleVersion is 3 segments for
Major.Minor.Build. This aligns with SemVer v1.0.0.
A hyphen is the delimiter between the Build number and the Prerelease string. A
hyphen may be
included in the Prerelease string as the first character, only.
The Prerelease string may contain only ASCII alphanumerics [0-9A-Za-z-]. It is a
best practice to
begin the Prerelease string with an alpha character, as it will be
easier to identify that this
is a prerelease version when scanning a list of packages.
Only SemVer v1.0.0 prerelease strings are supported at this time. Prerelease string
must not
contain either period or + [.+], which are allowed in SemVer 2.0.
Examples of supported Prerelease string are: -alpha, -alpha1, -BETA, -
update20171020
The only exceptions to this in the PowerShellGet module commands are Get-
InstalledModule, and some cases with Uninstall-Module.
Examples
Assume the PowerShell Gallery has TestPackage module versions 1.8.0 and 1.9.0-alpha. If
-AllowPrerelease is not specified, only version 1.8.0 will be returned.
PowerShell
find-module TestPackage
Output
PowerShell
Output
PowerShell
Output
At C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.6.0\PSModule.psm1:1455
char:3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound:
(Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
+ FullyQualifiedErrorId :
NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindP
ackage
The previous command failed because -AllowPrerelease was not specified. Adding -
AllowPrerelease
will result in success.
PowerShell
Get-InstalledModule TestPackage
Output
Side-by-side installation of versions of a module that differ only due to the prerelease
specified
is not supported. When installing a module using PowerShellGet, different
versions of the same
module are installed side-by-side by creating a folder name using
the ModuleVersion. The
ModuleVersion, without the prerelease string, is used for the
folder name. If a user installs
MyModule version 2.5.0-alpha, it will be installed to the
MyModule\2.5.0 folder. If the user then
installs 2.5.0-beta, the 2.5.0-beta version will
PowerShell
PowerShell
C:\windows\system32> Get-InstalledModule TestPackage -AllVersions
At line:1 char:1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ FullyQualifiedErrorId :
AllowPrereleaseRequiredToUsePrereleaseStringInVersion,Uninstall-Module
More details
Prerelease Script Versions
Find-Module
Install-Module
Save-Module
Update-Module
Get-InstalledModule
UnInstall-Module
Prerelease versions of scripts
Article • 04/17/2023
Starting with version 1.6.0, PowerShellGet and the PowerShell Gallery provide support
for tagging
versions greater than 1.0.0 as a prerelease. Prior to this feature, prerelease
packages were limited
to having a version beginning with 0. The goal of these features
is to provide greater support for
SemVer v1.0.0 versioning convention without
breaking
backwards compatibility with PowerShell versions 3 and above, or existing
versions of
PowerShellGet. This topic focuses on the script-specific features. The
equivalent features for
modules are in the Prerelease Module Versions topic. Using these
features, publishers can identify a script as version 2.5.0-alpha, and later release a
production-ready version 2.5.0 that supersedes the prerelease version.
Adding a PrereleaseString suffix to the version string in the script manifest. When
the scripts
is published to the PowerShell Gallery, this data is extracted from the
manifest, and used to
identify prerelease packages.
Acquiring prerelease packages requires adding -AllowPrerelease flag to the
PowerShellGet commands
Find-Script, Install-Script, Update-Script, and Save-
Script. If the flag is not specified,
prerelease packages will not be shown.
Script versions displayed by Find-Script, Get-InstalledScript, and in the PowerShell
Gallery will
be displayed with the PrereleaseString, as in 2.5.0-alpha.
An example section of a script manifest with a prerelease version would look like the
following:
PowerShell
<#PSScriptInfo
.VERSION 3.2.1-alpha12
.GUID
...
#>
To use a prerelease suffix, the version string must meet the following requirements:
A prerelease suffix may only be specified when the Version is 3 segments for
Major.Minor.Build.
This aligns with SemVer v1.0.0
The prerelease suffix is a string which begins with a hyphen, and may contain ASCII
alphanumerics
[0-9A-Za-z-]
Only SemVer v1.0.0 prerelease strings are supported at this time, so the prerelease
suffix
must not contain either period or + [.+], which are allowed in SemVer 2.0
Examples of supported PrereleaseString strings are: -alpha, -alpha1, -BETA, -
update20171020
When publishing to the PowerShell Gallery, by default the version of the script being
published
must have a greater version than any previously-published version that is in
the PowerShell
Gallery. A publisher may update version 2.5.0-alpha with 2.5.0-beta, or
with 2.5.0 (with no
prerelease suffix).
The only exceptions to this in the PowerShellGet script commands are Get-
InstalledScript, and some
cases with Uninstall-Script.
Examples
PowerShell
# Assume the PowerShell Gallery has TestPackage versions 1.8.0 and 1.9.0-
alpha.
At C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.6.0\PSModule.psm1:1455
char:3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound:
(Microsoft.Power...ets.FindPackage:FindPackage)[Find-Package], Exception
+ FullyQualifiedErrorId :
NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindP
ackage
Uninstall-Script will remove the current version of a script when -RequiredVersion is not
supplied.
If -RequiredVersion is specified, and is a prerelease, -AllowPrerelease must be
added to the command.
PowerShell
At line:1 char:1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ FullyQualifiedErrorId :
AllowPrereleaseRequiredToUsePrereleaseStringInVersion,Uninstall-script
# Since script versions are not installed side-by-side, the above could be
simply "Uninstall-Script TestPackage"
At C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.5.0.0\PSModule.psm1:4088
char:9
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound:
(Microsoft.Power...lets.GetPackage:GetPackage) [Get-Package], Exception
+ FullyQualifiedErrorId :
NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage
More details
Prerelease Module Versions
Find-script
Install-script
Save-script
Update-script
Get-Installedscript
UnInstall-script
ScriptAnalyzer rule profile for Gallery
Article • 04/17/2023
ScriptAnalyzer results will be displayed on each individual package page in Gallery in the
coming
release. We encourage package owners to check their packages to make sure
there are no severe errors
in published packages.
Report abuse
Article • 04/17/2023
If you find a package that is in violation of any of these items, click the Report Abuse
link on
the package details page and submit a report.
Dispute resolution
Article • 04/17/2023
Process
1. Contact the owners of the package you have the dispute with using the Contact
Owners link on
the package details page. Explain your issue in a kind and direct
manner.
2. Send a copy of your message to cgadmin@microsoft.com so that
PowerShell
Gallery Administrators are aware of your dispute.
3. Wait a maximum of 30 days and if you don't have resolution notify
cgadmin@microsoft.com again.
The PowerShellGallery.com support team will get involved and try to work this out.
Prohibited Use
The following things are not allowed on the public PowerShell Gallery and will be
immediately
removed without discussion. Package owners will be notified if their
package is removed.
If you find a package that is in violation of any of these items, click the 'Report Abuse'
link on
the package details page and submit a report.
PowerShell
7 Note
The CDN for the PowerShell gallery is active for one name, psg-prod-
eastus.azureedge.net or
psg-prod-centralus.azureedge.net , at any given time. The
*.powershellgallery.com - website
go.microsoft.com - redirection service
7 Note
Cmdlets that interact with the PowerShell Gallery can fail with unexpected errors
when there is an
outage of the PowerShell Gallery services. To see the current status
of the PowerShell Gallery,
see the PowerShell Gallery Status
page on GitHub.
Bootstrap the NuGet provider and
NuGet.exe
Article • 04/17/2023
NuGet.exe is not included in the latest NuGet provider. For publish operations of either
a module
or script, PowerShellGet requires the binary executable NuGet.exe. Only the
NuGet provider is
required for all other operations, including find, install, save, and
uninstall.
PowerShellGet includes logic to handle either a combined bootstrap of the
NuGet provider and
NuGet.exe, or bootstrap of only the NuGet provider. In either case,
only a single prompt message
should occur. If the machine is not connected to the
Internet, the user or an administrator must
copy a trusted instance of the NuGet
provider and/or the NuGet.exe file to the disconnected
machine.
7 Note
Output
At line:1 char:1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Find-Module
PowerShell
Output
Output
NuGet.exe is required to continue
PowerShellGet requires NuGet.exe to publish an item to the NuGet-based
repositories. NuGet.exe must
At line:1 char:1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ FullyQualifiedErrorId : CouldNotInstallNuGetExe,Publish-Module
PowerShell
Output
Please allow few minutes for 'Contoso' to show up in the search results.
Output
now?
At line:1 char:1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ FullyQualifiedErrorId : CouldNotInstallNuGetBinaries,Publish-Module
PowerShell
Output
now?
Please allow few minutes for 'Contoso' to show up in the search results.
After following the process above to bootstrap an Internet connected machine, you will
find
provider files in the location:
C:\Program Files\PackageManagement\ProviderAssemblies\
The folder/file structure of the NuGet provider will be (possibly with a different version
number):
NuGet
--2.8.5.208
----Microsoft.PackageManagement.NuGetProvider.dll
Copy these folders and file using a trusted process to the offline machines. To use the
provider on
the offline machine, it must be imported. Run the following command on
the offline machine:
PowerShell
The most common use case for this scenario is when a private gallery is available to
support an
isolated environment. There are two options to obtain the NuGet.exe file.
One option is to bootstrap a machine that is Internet connected and copy the files to
the offline
machines using a trusted process. After bootstrapping the Internet connected
machine, the NuGet.exe
binary will be located in one of two folders:
If the Publish-Module or Publish-Script cmdlets were executed with elevated
permissions (As
an Administrator):
PowerShell
$env:ProgramData\Microsoft\Windows\PowerShell\PowerShellGet
PowerShell
$HOME\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\
In either case, the NuGet.exe file can be copied to any location in $env:PATH , but the
standard
locations are:
To make the executable available so that all users can use Publish-Module and
Publish-Script
cmdlets:
PowerShell
$env:ProgramData\Microsoft\Windows\PowerShell\PowerShellGet
To make the executable available to only a specific user, copy to the location within
only that
user's profile:
PowerShell
$HOME\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\
Overview
In May 2018, a European privacy law, the General Data Protection Regulation (GDPR),
took effect. The
GDPR imposes new rules on companies, government agencies, non-
profits, and other organizations that
offer goods and services to people in the European
Union (EU), or that collect and analyze data tied
to EU residents. The GDPR applies no
matter where you are located.
7 Note
This article provides steps for how to delete personal data from the PowerShell
Gallery and can be
used to support your obligations under the GDPR. If you're
looking for general info about GDPR,
see the
GDPR section of the Service Trust
portal .
Most users do not create a PowerShell Gallery account. An account is not required
unless you are
going to publish a package or use the "Contact Owner" feature in the
PowerShell Gallery. Other than
email correspondence initiated by the user, the
PowerShell Gallery does not store personally
identifiable data for users who have not
created an account.
Users who create a PowerShell Gallery account can publish packages to the PowerShell
Gallery. Those
packages are expected to be PowerShell code, but may contain other
information including personal
information. The information below will show how you
can get all the packages you have published to
the PowerShell Gallery.
DSR Export of PowerShell Gallery Data
The following sections describe how the PowerShell Gallery supports data subject
requests (DSR), by
explaining how to export information stored in the PowerShell
Gallery, and how to request deletion
of this information.
Email
Email correspondence may include any of the following:
Email sent to the owners of PowerShell Gallery packages if the code analysis scans
detected an
issue with any package they have published to the PowerShell Gallery
Email sent by anyone to the PowerShell Gallery team using the email address in the
"Contact Us"
page cgadmin@microsoft.com
Registered users who use the "Contact Owner" feature in the PowerShell Gallery to
send email to
the owner of a package in the PowerShell Gallery
Emails sent by or to the PowerShell Gallery have a retention policy of 90 days to support
possible
security investigations should malicious code be discovered on the PowerShell
Gallery. Emails are
deleted by policy after 90 days.
You may request copies of all emails sent to or from your email address and the
PowerShell Gallery
within the previous 90 days. To request this correspondence, send an
email to
cgadmin@microsoft.com, with the title: "DSR Request for emails
relating to this
account". In the body of the message, state what information you are requesting
(for
example: Please send all emails sent to or received from this email address.) All emails
involving your email address within 90 days of the request will be sent within 7 business
days.
If you have created more than one account in the PowerShell Gallery, you will need to
repeat these
steps for each account.
7 Note
The Author is stored in the package manifest when you publish your package.
There is no guarantee
that the Author is the same identity as the account you use
in the PowerShell Gallery. If you use
some other value in the Author field, you will
need to supply that value when using this script.
You may download the script by using the following PowerShell command:
PowerShell
You can then run the script directly, by running the following PowerShell commands:
PowerShell
.\GetPSGalleryItemsForAuthor.ps1
You will be prompted to supply the Author and a folder on your system where you want
the packages to
be saved.