Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Save-Script
- Module:
- PowerShellGet Module
Saves a script.
Syntax
NameAndPathParameterSet (Default)
Save-Script
[-Name] <String[]>
[-Path] <String>
[-MinimumVersion <String>]
[-MaximumVersion <String>]
[-RequiredVersion <String>]
[-Repository <String[]>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-Force]
[-AllowPrerelease]
[-AcceptLicense]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
NameAndLiteralPathParameterSet
Save-Script
[-Name] <String[]>
-LiteralPath <String>
[-MinimumVersion <String>]
[-MaximumVersion <String>]
[-RequiredVersion <String>]
[-Repository <String[]>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-Force]
[-AllowPrerelease]
[-AcceptLicense]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
InputObjectAndLiteralPathParameterSet
Save-Script
[-InputObject] <PSObject[]>
-LiteralPath <String>
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-Force]
[-AcceptLicense]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
InputObjectAndPathParameterSet
Save-Script
[-InputObject] <PSObject[]>
[-Path] <String>
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-Force]
[-AcceptLicense]
[-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
-AcceptLicense
Automatically accept the license agreement if the script requires it.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-AllowPrerelease
Allows you to save a script marked as a prerelease.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Confirm
Prompts you for confirmation before running Save-Script.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
-Credential
Specifies a user account that has permission to save a script.
Parameter properties
| Type: | PSCredential |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Force
Forces Save-Script to run without asking for user confirmation.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-InputObject
Accepts a PSRepositoryItemInfo object. For example, output Find-Script to a variable and use
that variable as the InputObject argument.
Parameter properties
| Type: | PSObject[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-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.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | PSPath |
Parameter sets
-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.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-MinimumVersion
Specifies the minimum version of a script to save. The MinimumVersion and RequiredVersion parameters can't be used in the same command.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Name
Specifies an array of script names to save.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Path
Specifies the location on the local computer to store a saved module. Accepts wildcard characters.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | True |
| DontShow: | False |
Parameter sets
-Proxy
Specifies a proxy server for the request, rather than connecting directly to an internet resource.
Parameter properties
| Type: | Uri |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ProxyCredential
Specifies a user account that has permission to use the proxy server specified by the Proxy parameter.
Parameter properties
| Type: | PSCredential |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Repository
Specifies the friendly name of a repository that has been registered by running
Register-PSRepository. Use Get-PSRepository to display registered repositories.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-RequiredVersion
Specifies the exact version number of the script to save.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIf
Shows what would happen if Save-Script runs. The cmdlet isn't run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
String
PSObject
String
Uri
PSCredential
Outputs
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
PowerShellGet
Feedback
Was this page helpful?
