Save-​Script

Saves a script.

Syntax

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

Description

The Save-Script cmdlet saves the specified script.

Examples

Example 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:\ScriptSharingDemo\Fabrikam-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.

Required Parameters

-InputObject

{{Fill InputObject Description}}

Type:PSObject[]
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False
-LiteralPath

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.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Name

Specifies an array of names of scripts to save.

Type:String[]
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Path

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

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-Credential

@{Text=}

Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-MaximumVersion

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.

Type:Version
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-MinimumVersion

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.

Type:Version
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Proxy

Specifies a proxy server for the request, rather than connecting directly to the Internet resource.

Type:Uri
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ProxyCredential

Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter.

Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Repository

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

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-RequiredVersion

Specifies the exact version number of the script to save.

Type:Version
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False