Save-Script

Saves a script.

Syntax

Save-Script
    [-Name] <String[]>
    [-MinimumVersion <Version>]
    [-MaximumVersion <Version>]
    [-RequiredVersion <Version>]
    [-Repository <String[]>]
    -Path <String>
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Credential <PSCredential>]
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
Save-Script
    [-Name] <String[]>
    [-MinimumVersion <Version>]
    [-MaximumVersion <Version>]
    [-RequiredVersion <Version>]
    [-Repository <String[]>]
    -LiteralPath <String>
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Credential <PSCredential>]
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
Save-Script
    -InputObject <PSObject[]>
    -LiteralPath <String>
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Credential <PSCredential>]
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
Save-Script
    -InputObject <PSObject[]>
    -Path <String>
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Credential <PSCredential>]
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<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: Named
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: 1
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
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
Type: Uri
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-ProxyCredential
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