| external help file | PSModule-help.xml |
|---|---|
| Locale | en-US |
| Module Name | PowerShellGet |
| ms.custom | 3.0.22-beta22 |
| ms.date | 09/19/2023 |
| online version | https://learn.microsoft.com/powershell/module/powershellget/save-script?view=powershellget-2.x&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
| title | Save-Script |
Saves a script.
Save-Script [-Name] <String[]> [-MinimumVersion <String>] [-MaximumVersion <String>]
[-RequiredVersion <String>] [-Repository <String[]>] [-Path] <String> [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-AllowPrerelease]
[-AcceptLicense] [-WhatIf] [-Confirm] [<CommonParameters>]
Save-Script [-Name] <String[]> [-MinimumVersion <String>] [-MaximumVersion <String>]
[-RequiredVersion <String>] [-Repository <String[]>] -LiteralPath <String> [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-AllowPrerelease]
[-AcceptLicense] [-WhatIf] [-Confirm] [<CommonParameters>]
Save-Script [-InputObject] <PSObject[]> -LiteralPath <String> [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-AcceptLicense] [-WhatIf]
[-Confirm] [<CommonParameters>]
Save-Script [-InputObject] <PSObject[]> [-Path] <String> [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-Credential <PSCredential>] [-Force] [-AcceptLicense] [-WhatIf]
[-Confirm] [<CommonParameters>]
The Save-Script cmdlet saves the specified script.
This is a proxy cmdlet for the Save-PSResource cmdlet in the
Microsoft.PowerShell.PSResourceGet. For more information, see
Save-PSResource.
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.ps1Version 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.
The proxy cmdlet ignores this parameter since it's not supported by Save-PSResource.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe proxy cmdlet maps this parameter to the Prerelease parameter of Save-PSResource.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies 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: FalseThe proxy cmdlet ignores this parameter since it's not supported by Save-PSResource.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseAccepts 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: InputObjectAndLiteralPathParameterSet, InputObjectAndPathParameterSet
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: FalseSpecifies 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.
The proxy cmdlet maps this parameter to the Path parameter of Save-PSResource.
Type: System.String
Parameter Sets: NameAndLiteralPathParameterSet, InputObjectAndLiteralPathParameterSet
Aliases: PSPath
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseThe proxy cmdlet uses the value of this parameter to create a NuGet version search string for use
with the Version parameter of Save-PSResource.
Type: System.String
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseThe proxy cmdlet uses the value of this parameter to create a NuGet version search string for use
with the Version parameter of Save-PSResource.
Type: System.String
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseSpecifies 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: FalseSpecifies the location on the local computer to store a saved module. Accepts wildcard characters.
Type: System.String
Parameter Sets: NameAndPathParameterSet, InputObjectAndPathParameterSet
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: TrueThe proxy cmdlet ignores this parameter since it's not supported by Save-PSResource.
Type: System.Uri
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseThe proxy cmdlet ignores this parameter since it's not supported by Save-PSResource.
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseSpecifies 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: FalseThe proxy cmdlet uses the value of this parameter to create a NuGet version search string for use
with the Version parameter of Save-PSResource.
Type: System.String
Parameter Sets: NameAndPathParameterSet, NameAndLiteralPathParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalsePrompts 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: FalseShows 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: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
The PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. You must use TLS 1.2 or higher. Use the following command to ensure you are using TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12