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.
Get-PSRepository displays the local computer's registered repositories. You can use the
Find-Module cmdlet to search registered repositories.
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
-Confirm
Prompts you for confirmation before running the Save-Module.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
cf
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Force
Forces Save-Module to run without asking for user confirmation.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-InputObject
Accepts a PSRepositoryItemInfo object. For example, output Find-Module to a variable and use
that variable as the InputObject argument.
Parameter properties
Type:
PSObject[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
InputObjectAndLiteralPathParameterSet
Position:
0
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
True
Value from remaining arguments:
False
InputObjectAndPathParameterSet
Position:
0
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
True
Value from remaining arguments:
False
-LiteralPath
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.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
NameAndLiteralPathParameterSet
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
InputObjectAndLiteralPathParameterSet
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-MaximumVersion
Specifies the maximum, or newest, version of the module to save. The MaximumVersion and
RequiredVersion parameters can't be used in the same command.
Parameter properties
Type:
Version
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
NameAndPathParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
NameAndLiteralPathParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-MinimumVersion
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.
Parameter properties
Type:
Version
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
Version
Parameter sets
NameAndPathParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
NameAndLiteralPathParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-Name
Specifies an array of names of modules to save.
Parameter properties
Type:
String[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
NameAndPathParameterSet
Position:
0
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
NameAndLiteralPathParameterSet
Position:
0
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-Path
Specifies the location on the local computer to store a saved module. Accepts wildcard characters.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
True
DontShow:
False
Parameter sets
NameAndPathParameterSet
Position:
1
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
InputObjectAndPathParameterSet
Position:
1
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Repository
Specifies the friendly name of a repository that has been registered by running
Register-PSRepository. Use Get-PSRepository to display registered repositories.
Parameter properties
Type:
String[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
NameAndPathParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
NameAndLiteralPathParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-RequiredVersion
Specifies the exact version number of the module to save.
Parameter properties
Type:
Version
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
NameAndPathParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
NameAndLiteralPathParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-WhatIf
Shows what would happen if the Save-Module runs. The cmdlet isn't run.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
wi
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.