Save-Module

Updated: August 9, 2015

Save-Module

Saves a module locally without installing it.

Syntax

Parameter Set: NameAndPathParameterSet
Save-Module [-Force] [-InputObject] <PSObject[]> [-MaximumVersion] <Version> [-MinimumVersion] <Version> [-Name] <String[]> [-Path] <String> [-Repository] <String[]> [-RequiredVersion] <Version> 

Parameter Set: InputOjectAndLiteralPathParameterSet
Save-Module [-Force] [-InputObject] <PSObject[]> [-LiteralPath] <String> 

Parameter Set: InputOjectAndPathParameterSet
Save-Module [-Force] [-InputObject] <PSObject[]> [-Path] <String> 

Parameter Set: NameAndLiteralPathParameterSet
Save-Module [-Force] [-InputObject] <PSObject[]> [-LiteralPath] <String> [-MaximumVersion] <Version> [-MinimumVersion] <Version> [-Name] <String[]> [-Repository] <String[]> [-RequiredVersion] <Version> 




Detailed Description

The Save-Module cmdlet lets you save a gallery-based module locally without installing it. This lets you inspect the module’s contents before you install a module, helping to minimize the risks of malicious code or malware on your system.

As a best practice, when you have finished evaluating a module for potential risks, and before you install the module for use, delete the module from the path to which you have saved it.

Parameters

-Force

Forces the specified modules to be saved. If a module of the same name and version already exists in the specified path, this parameter overwrites the existing module with one of the same name that was found by the command.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-InputObject<PSObject[]>

Specifies a PSGetItemInfo object. You can run Find-Module to obtain a PSGetItemInfo object that you can pipe into Save-Module.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-LiteralPath<String>

Specifies an exact path to which you want to save the module. For best results, enclose paths in quotation marks.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-MaximumVersion<Version>

Specifies the maximum version of a single module to save. You cannot add this parameter if you are attempting to save multiple modules. The MaximumVersion and the RequiredVersion parameters are mutually exclusive; you cannot use both parameters in the same command.


Aliases

Version

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-MinimumVersion<Version>

Specifies the minimum version of a single module to save to your local computer. You cannot add this parameter if you are attempting to save multiple modules. The MinimumVersion and the RequiredVersion parameters are mutually exclusive; you cannot use both parameters in the same command.

If you are saving multiple modules in a single command, and a specified minimum version for a module is not available, the Save-Module command will silently continue without saving the module for which it cannot find the specified minimum version. For example, if you try to save the ContosoServer module with a minimum version of 2.0, but the newest version of the ContosoServer module is only 1.5, your Save-Module command will not save the ContosoServer module; it will go on to save the next specified module, and Windows PowerShell will display errors when the command is finished.


Aliases

Version

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Name<String[]>

Specifies the exact names of modules to save from the online gallery. This parameter supports wildcard characters. If wildcard characters are not specified, only modules that exactly match the specified names are returned. If no matches are found, and you have not used any wildcard characters, the command returns an error. If you use wildcard characters, but do not find matching results, no error is returned. (This follows standard wildcard character matching behavior for Windows PowerShell.)


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Path<String>

Specifies a path to which you want to save the module. For best results, enclose paths in quotation marks.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Repository<String[]>

The friendly name of a repository that has been registered by running Register-PSRepository. The repository must have a PublishLocation, which is a valid NuGet URI. The PublishLocation can be set by running Set-PSRepository. The default value of this parameter is PSGallery.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-RequiredVersion<Version>

The exact version of a single module to save. You cannot add this parameter if you are attempting to save multiple modules, or use this parameter in the same command with either the MinimumVersion or MaximumVersion parameters.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • PSModuleInfo

    You can pipe PSModuleInfo object to Save-Module.


Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

-------------------------- EXAMPLE 1 --------------------------

In this example, you save only version 2.5 of a module named FabrikamServer to a path, C:\TestUser\ModulesToCheck, where you can later evaluate the module for risks before installing it.


Save-Module -Name FabrikamServer -RequiredVersion 2.5 -Path C:\TestUser\ModulesToCheck

Community Additions

Show: