PowerShell Commands

Save-Module

Save-Module [-InputObject*] <PSObject[]> [-Confirm] [-Credential <PSCredential>] [-Force] -LiteralPath* <String>[-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-WhatIf] [<CommonParameters>]
Save-Module [-InputObject*] <PSObject[]> [-Confirm] [-Credential <PSCredential>] [-Force] -Path* <String> [-Proxy<Uri>] [-ProxyCredential <PSCredential>] [-WhatIf] [<CommonParameters>]
Save-Module [-Name*] <String[]> [-Confirm] [-Credential <PSCredential>] [-Force] -LiteralPath* <String>[-MaximumVersion <Version>] [-MinimumVersion <Version>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>][-Repository <String[]>] [-RequiredVersion <Version>] [-WhatIf] [<CommonParameters>]
Save-Module [-Name*] <String[]> [-Confirm] [-Credential <PSCredential>] [-Force] [-MaximumVersion <Version>][-MinimumVersion <Version>] -Path* <String> [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-Repository<String[]>] [-RequiredVersion <Version>] [-WhatIf] [<CommonParameters>]

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

Parameters

-Confirm [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

Prompts you for confirmation before running the cmdlet.

-Credential <PSCredential>

  • Default value is None
  • Accepts pipeline input ByPropertyName

@{Text=}

-Force [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

Forces the command to run without asking for user confirmation.

-InputObject <PSObject[]>

  • This value is required
  • Default value is None
  • Accepts pipeline input ByPropertyName

{{Fill InputObject Description}}

-LiteralPath <String>

  • This value is required
  • Default value is None
  • Accepts pipeline input False

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>

  • Default value is None
  • Accepts pipeline input ByPropertyName

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>

  • Default value is None
  • Accepts pipeline input ByPropertyName

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[]>

  • This value is required
  • Default value is None
  • Accepts pipeline input ByPropertyName

Specifies an array of names of modules to save.

-Path <String>

  • This value is required
  • Default value is None
  • Accepts pipeline input False

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.

-Proxy <Uri>

  • Default value is None
  • Accepts pipeline input ByPropertyName

@{Text=}

-ProxyCredential <PSCredential>

  • Default value is None
  • Accepts pipeline input ByPropertyName

@{Text=}

-Repository <String[]>

  • Default value is None
  • Accepts pipeline input ByPropertyName

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

-RequiredVersion <Version>

  • Default value is None
  • Accepts pipeline input ByPropertyName

Specifies the exact version number of the module to save.

-WhatIf [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

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 cmdlets PS 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 Manager PS 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.profile PS 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.

Additional Notes

This work is licensed under a Creative Commons Attribution 4.0 International. It is attributed to Microsoft Corporation and can be found here.

PowerShell Commands