Save-Script

Saves a script.
Save-Script [-Name*] <String[]> [-Force] [-MaximumVersion [<Version>]] [-MinimumVersion [<Version>]] [-Repository[<String[]>]] [-RequiredVersion [<Version>]] -Path* <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Save-Script [-Name*] <String[]> [-Force] [-MaximumVersion [<Version>]] [-MinimumVersion [<Version>]] [-Repository[<String[]>]] [-RequiredVersion [<Version>]] -LiteralPath* <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Save-Script [-Force] -LiteralPath* <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Save-Script [-Force] -Path* <String> [-Confirm] [-WhatIf] [<CommonParameters>]

The Save-Script cmdlet saves the specified script.

Parameters
-Force [<SwitchParameter>]

Forces the command to run without asking for user confirmation.

-LiteralPath <String>

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. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

-MaximumVersion [<Version>]

Specifies the maximum, or newest version of the script 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 the script to find. The MinimumVersion and the RequiredVersion parameters are mutually exclusive; you cannot use both parameters in the same command.

-Name <String[]>

Specifies an array of names of scripts to save.

-Path <String>

Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory (.).

-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 script 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. Save a script and validate it:
    PS C:> Save-Script -Name "Fabrikam-ClientScript" -Repository "Local01" -Path "D:ScriptSharingDemo"
    PS C:>  Test-ScriptFileInfo -Path "D:ScriptSharingDemoFabrikam-ClientScript.ps1"
    
       Version    Name                      Author               Description
       -------    ----                      ------               -----------
       2.5        Fabrikam-ClientScript     pattif               Description for the Fabrikam-ClientScript script

    The first command saves the script Fabrikam-ClientScript from the Local01 repository to the local folder D:ScriptSharingDemo.

    The second command uses the Test-ScriptFileInfo cmdlet to validate the script.

Related Links

Find-Script
Install-Script
Publish-Script
Uninstall-Script
Update-Script