Skip to content

Latest commit

 

History

History
362 lines (266 loc) · 8.73 KB

File metadata and controls

362 lines (266 loc) · 8.73 KB
external help file PSModule-help.xml
Locale en-US
Module Name PowerShellGet
ms.date 07/02/2019
online version https://learn.microsoft.com/powershell/module/powershellget/save-script?view=powershellget-1.x&WT.mc_id=ps-gethelp
schema 2.0.0
title Save-Script

Save-Script

SYNOPSIS

Saves a script.

SYNTAX

NameAndPathParameterSet (Default)

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

NameAndLiteralPathParameterSet

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

InputOjectAndLiteralPathParameterSet

Save-Script [-InputObject] <PSObject[]> -LiteralPath <String> [-Proxy <Uri>]
 [-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-WhatIf] [-Confirm]
 [<CommonParameters>]

InputOjectAndPathParameterSet

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 the script's metadata

In this example, a script from a repository is saved to the local computer and the script's metadata is validated.

Save-Script -Name Install-VSCode -Repository PSGallery -Path C:\Test\Scripts
Test-ScriptFileInfo -Path C:\Test\Scripts\Install-VSCode.ps1
Version   Name              Author      Description
-------   ----              ------      -----------
1.3       Install-VSCode    Microsoft   This script can be used to easily install Visual Studio Code

Save-Script uses the Name parameter to specify the script's name. The Repository parameter specifies where to find the script. The script is saved in the location specified by the Path parameter. Test-ScriptFileInfo specifies the Path and validates the script's metadata.

PARAMETERS

-Credential

Specifies a user account that has permission to save a script.

Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:

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

-Force

Forces Save-Script to run without asking for user confirmation.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-InputObject

Accepts a PSRepositoryItemInfo object. For example, output Find-Script to a variable and use that variable as the InputObject argument.

Type: System.Management.Automation.PSObject[]
Parameter Sets: InputOjectAndLiteralPathParameterSet, InputOjectAndPathParameterSet
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-LiteralPath

Specifies a path to one or more locations. The value of the LiteralPath parameter is used exactly as entered. No characters are interpreted as wildcards. If the path includes escape characters, enclose the path within single quotation marks. PowerShell doesn't interpret any characters enclosed in single quotation marks as escape sequences.

Type: System.String
Parameter Sets: NameAndLiteralPathParameterSet, InputOjectAndLiteralPathParameterSet
Aliases:

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

-MaximumVersion

Specifies the maximum, or newest version of the script to save. The MaximumVersion and RequiredVersion parameters can't be used in the same command.

Type: System.Version
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:

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

-MinimumVersion

Specifies the minimum version of a script to save. The MinimumVersion and RequiredVersion parameters can't be used in the same command.

Type: System.Version
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:

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

-Name

Specifies an array of script names to save.

Type: System.String[]
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Path

Specifies the location on the local computer to store a saved module. Accepts wildcard characters.

Type: System.String
Parameter Sets: NameAndPathParameterSet, InputOjectAndPathParameterSet
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True

-Proxy

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

Type: System.Uri
Parameter Sets: (All)
Aliases:

Required: False
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 specified by the Proxy parameter.

Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:

Required: False
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. Use Get-PSRepository to display registered repositories.

Type: System.String[]
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:

Required: False
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: System.Version
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:

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

-Confirm

Prompts you for confirmation before running Save-Script.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if Save-Script runs. The cmdlet isn't run.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String[]

System.Management.Automation.PSObject[]

System.Version

System.String

System.Uri

System.Management.Automation.PSCredential

OUTPUTS

System.Object

NOTES

Important

As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. If you are not using TLS 1.2 or higher, you will receive an error when trying to access the PowerShell Gallery. Use the following command to ensure you are using TLS 1.2:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

For more information, see the announcement in the PowerShell blog.

RELATED LINKS

Find-Script

Install-Script

Publish-Script

Test-ScriptFileInfo

Uninstall-Script

Update-Script