The Save-Module cmdlet downloads a module and any dependencies from a registered repository.
Save-Module downloads and saves the most current version of a module. The files are saved to a
specified path on the local computer. The module isn't installed, but the contents are available for
inspection by an administrator. The saved module can then be copied into the appropriate
$env:PSModulePath location of the offline machine.
Get-PSRepository displays the local computer's registered repositories. You can use the
Find-Module cmdlet to search registered repositories.
The parameters that take module version numbers expect strings formatted as version numbers.
Standard version numbers have a format of x.y.z where x, y, and z are numbers
Prerelease versions have a format of x.y.z-<prerelease_label> where the <prerelease_label> is
arbitrary string assigned to that release.
Examples
Example 1: Save a module
In this example, a module and its dependencies are saved to the local computer.
Save-Module uses the Name parameter to specify the module, PowerShellGet. The Path
parameter specifies where to store the downloaded module. The Repository parameter specifies a
registered repository, PSGallery. After the download is finished, Get-ChildItem displays the
contents of Path where the files are stored.
Example 2: Save a specific version of a module
This example shows how to use a parameter such as MaximumVersion, or RequiredVersion to
specify a module version.
Save-Module uses the Name parameter to specify the module, PowerShellGet. The Path
parameter specifies where to store the downloaded module. The Repository parameter specifies a
registered repository, PSGallery. MaximumVersion specifies that version 2.1.0 is
downloaded and saved. After the download is finished, Get-ChildItem displays the contents of
Path where the files are stored.
Example 3: Find and save a specific version of a module
In this example, a required module version is found in the repository and saved to the local
computer.
Find-Module uses the Name parameter to specify the module, PowerShellGet. The
Repository parameter specifies a registered repository, PSGallery. RequiredVersion
specifies version 1.6.5.
The object is sent down the pipeline to Save-Module. The Path parameter specifies where to
store the downloaded module. After the download is finished, Get-ChildItem displays the contents
of Path where the files are stored.
Parameters
-AcceptLicense
Automatically accept the license agreement if the package requires it.
Specifies a path to one or more locations. The value of the LiteralPath parameter is used
exactly as entered. No characters are interpreted as wildcards. If the path includes escape
characters, enclose them in single quotation marks. PowerShell does not interpret any characters
enclosed in single quotation marks as escape sequences.
Specifies the minimum version of a single module to save. You cannot add this parameter if you are
attempting to install multiple modules. The MinimumVersion and RequiredVersion parameters
can't be used in the same command.
Specifies the friendly name of a repository that has been registered by running
Register-PSRepository. Use Get-PSRepository to display registered repositories.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
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:
For more information, see the
announcement in the
PowerShell blog.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.