Save-Module

Saves a module locally without installing it.
Save-Module [-Name*] <String[]> [-Force] [-MaximumVersion [<Version>]] [-MinimumVersion [<Version>]] [-Repository[<String[]>]] [-RequiredVersion [<Version>]] -Path* <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Save-Module [-Name*] <String[]> [-Force] [-MaximumVersion [<Version>]] [-MinimumVersion [<Version>]] [-Repository[<String[]>]] [-RequiredVersion [<Version>]] -LiteralPath* <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Save-Module [-Force] -LiteralPath* <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Save-Module [-Force] -Path* <String> [-Confirm] [-WhatIf] [<CommonParameters>]

The Save-Module cmdlet saves a module locally from the specified repository for inspection. The module is not installed.

Parameters
-Force [<SwitchParameter>]

Forces the command to run without asking for user confirmation.

-LiteralPath <String>

  • This value is required

Specifies a path to one or more locations. Unlike the Path parameter, 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. Windows PowerShell does not interpret any characters that are enclosed in single quotation marks as escape sequences.

-MaximumVersion [<Version>]

Specifies the maximum, or newest, version of the module to save. The MaximumVersion and RequiredVersion parameters are mutually exclusive; you cannot use both parameters in the same command.

-MinimumVersion [<Version>]

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 are mutually exclusive; you cannot use both parameters in the same command.

-Name <String[]>

Specifies an array of names of modules to save.

-Path <String>

  • This value is required

Specifies the path to the module that you want to publish. This parameter accepts either the path to the folder that contains the module, or the module manifest (.psd1) file. The parameter accepts piped values from Get-Module.

-Repository [<String[]>]

Specifies the friendly name of a repository that has been registered by running Register-PSRepository.

-RequiredVersion [<Version>]

Specifies the exact version number of the module to save.

-Confirm [<SwitchParameter>]

  • Default value is false

Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet.

-WhatIf [<SwitchParameter>]

  • Default value is false

Shows what would happen if the cmdlet runs. The cmdlet is not run.Shows what would happen if the cmdlet runs. The cmdlet is not run.

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable.

Examples
  1. Find modules and save them locally:
    PS C:> Find-Module -Name "AzureAutomationDebug" -Repository "PSGallery"
    
       Version    Name                                Type       Repository           Description
       -------    ----                                ----       ----------           -----------
       1.3.5      AzureAutomationDebug                Module     PSGallery            Module for debugging Azure 
       Automation runbooks, emulating AA native cmdletsPS C:>Find-Module -Name "AzureAutomationDebug" -Repository 
       "PSGallery" -IncludeDependencies
       Version    Name                                Type       Repository           Description
       -------    ----                                ----       ----------           -----------
       1.3.5      AzureAutomationDebug                Module     PSGallery            Module for debugging Azure 
       Automation runbooks, emulating AA native cmdlets
       1.0.1      AzureRM.Automation                  Module     PSGallery            Microsoft Azure PowerShell - 
       Automation service cmdlets for Azure Resource Manager
       1.0.1      AzureRM.profile                     Module     PSGallery            Microsoft Azure PowerShell - 
       Profile credential management cmdlets for Azure Resource ManagerPS C:>Find-Module -Name "AzureAutomationDebug" 
       -Repository "PSGallery" | Save-Module -Path "C:MyLocalModules"
    
    PS C:>  dir C:MyLocalModules
    
           Directory: C:MyLocalModules
       Mode                LastWriteTime         Length Name
       ----                -------------         ------ ----
       d-----       12/14/2015  11:20 AM                AzureAutomationDebug
       d-----       12/14/2015  11:20 AM                AzureRM.Automation
       d-----       12/14/2015  11:20 AM                AzureRM.profilePS C:>Save-Module -LiteralPath 
       "C:MyLocalModules" -Name "xPSDesiredStateConfiguration" -Repository "PSGallery" -MinimumVersion 2.0 
       -MaximumVersion 3.5.0
    
    PS C:>  dir C:MyLocalModules
    
          Directory: C:MyLocalModules
       Mode                LastWriteTime         Length Name
       ----                -------------         ------ ----
       d-----       12/14/2015  11:22 AM                xPSDesiredStateConfiguration

    The first command uses the Find-Module cmdlet to find the AzureAutomationDebug module in the PSGallery repository and displays the results.

    The second command uses Find-Module to find the AzureAutomationDebug module and its dependencies, and displays the results.

    The third command uses Find-Module to find the AzureAutomationDebug module, and then uses the pipeline operator to pass the module to the Save-Module cmdlet, which save the module to the specified folder.

    The fourth command displays the contents of the saved module.

    The fifth command saves the specified versions of the module xPSDesiredStateConfiguration to C:MyLocalModules.

    The final command displays the contents of the C:MyLocalModules folder.

Related Links

Find-Module
Import-Module
Publish-Module
Uninstall-Module
Update-Module