external help file | Locale | Module Name | ms.date | online version | schema | title |
---|---|---|---|---|---|---|
PSModule-help.xml |
en-US |
PowerShellGet |
12/09/2022 |
2.0.0 |
Save-Module |
Saves a module and its dependencies on the local computer but doesn't install the module.
Save-Module [-Name] <String[]> [-MinimumVersion <String>] [-MaximumVersion <String>]
[-RequiredVersion <String>] [-Repository <String[]>] [-Path] <String> [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-AllowPrerelease]
[-AcceptLicense] [-WhatIf] [-Confirm] [<CommonParameters>]
Save-Module [-Name] <String[]> [-MinimumVersion <String>] [-MaximumVersion <String>]
[-RequiredVersion <String>] [-Repository <String[]>] -LiteralPath <String> [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-AllowPrerelease]
[-AcceptLicense] [-WhatIf] [-Confirm] [<CommonParameters>]
Save-Module [-InputObject] <PSObject[]> -LiteralPath <String> [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-AcceptLicense] [-WhatIf]
[-Confirm] [<CommonParameters>]
Save-Module [-InputObject] <PSObject[]> [-Path] <String> [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-AcceptLicense] [-WhatIf]
[-Confirm] [<CommonParameters>]
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.
In this example, a module and its dependencies are saved to the local computer.
Save-Module -Name PowerShellGet -Path C:\Test\Modules -Repository PSGallery
Get-ChildItem -Path C:\Test\Modules
Directory: C:\Test\Modules
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/1/2019 13:31 PackageManagement
d----- 7/1/2019 13:31 PowerShellGet
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.
This example shows how to use a parameter such as MaximumVersion, or RequiredVersion to specify a module version.
Save-Module -Name PowerShellGet -Path C:\Test\Modules -Repository PSGallery -MaximumVersion 2.1.0
Get-ChildItem -Path C:\Test\Modules\PowerShellGet\
Directory: C:\Test\Modules\PowerShellGet
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/1/2019 13:40 2.1.0
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.
In this example, a required module version is found in the repository and saved to the local computer.
Find-Module -Name PowerShellGet -Repository PSGallery -RequiredVersion 1.6.5 |
Save-Module -Path C:\Test\Modules
Get-ChildItem -Path C:\Test\Modules\PowerShellGet
Directory: C:\Test\Modules\PowerShellGet
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/1/2019 14:04 1.6.5
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.
Automatically accept the license agreement if the package requires it.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Allows you to save a module marked as a prerelease.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies a user account that has rights to save a module.
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
If the location specified by the Path parameter doesn't exist, the cmdlet returns an error. Using the Force parameter creates the target path.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Accepts a PSRepositoryItemInfo object. For example, output Find-Module
to a variable and use
that variable as the InputObject argument.
Type: System.Management.Automation.PSObject[]
Parameter Sets: InputObjectAndLiteralPathParameterSet, InputObjectAndPathParameterSet
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
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.
Type: System.String
Parameter Sets: NameAndLiteralPathParameterSet, InputObjectAndLiteralPathParameterSet
Aliases: PSPath
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the maximum, or newest, version of the module to save. The MaximumVersion and RequiredVersion parameters can't be used in the same command.
Type: System.String
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
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.
Type: System.String
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies an array of names of modules to save.
Type: System.String[]
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the location on the local computer to store a saved module. Accepts wildcard characters.
Type: System.String
Parameter Sets: NameAndPathParameterSet, InputObjectAndPathParameterSet
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True
Specifies a proxy server for the request, rather than connecting directly to the internet resource.
Type: System.Uri
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter.
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the friendly name of a repository that has been registered by running
Register-PSRepository
. Use Get-PSRepository
to display registered repositories.
Type: System.String[]
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the exact version number of the module to save.
Type: System.String
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Prompts you for confirmation before running the Save-Module
.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the Save-Module
runs. The cmdlet isn't run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Important
As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. If you are not using TLS 1.2 or higher, you will receive an error when trying to access the PowerShell Gallery. Use the following command to ensure you are using TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
For more information, see the announcement in the PowerShell blog.