Update-Script

Updates a script.

Syntax

Update-Script
      [[-Name] <String[]>]
      [-RequiredVersion <String>]
      [-MaximumVersion <String>]
      [-Proxy <Uri>]
      [-ProxyCredential <PSCredential>]
      [-Credential <PSCredential>]
      [-Force]
      [-AllowPrerelease]
      [-AcceptLicense]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

The Update-Script cmdlet updates a script that is installed on the local computer. The updated script is downloaded from the same repository as the installed version.

Examples

Example 1: Update the specified script

This example updates an installed script and displays the updated version.

Update-Script -Name UpdateManagement-Template -RequiredVersion 1.1
Get-InstalledScript -Name UpdateManagement-Template

Version   Name                       Repository   Description
-------   ----                       ----------   -----------
1.1       UpdateManagement-Template  PSGallery    This is a template script for Update Management...

Update-Script uses the Name parameter to specify the script to update. The RequiredVersion parameter specifies the script version. Get-InstalledScript displays the updated version of the script.

Parameters

-AcceptLicense

Automatically accept the license agreement during installation if the package requires it.

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

-AllowPrerelease

Allows you to update a script with the newer script marked as a prerelease.

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

-Confirm

Prompts you for confirmation before running Update-Script.

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

-Credential

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

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

-Force

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

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

-MaximumVersion

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

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

-Name

Specifies one script name or an array of script names to update.

Type:String[]
Position:0
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

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

-Proxy

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

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

-ProxyCredential

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

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

-RequiredVersion

Specifies the exact version number of the script to update. The MinimumVersion and RequiredVersion parameters can't be used in the same command.

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

-WhatIf

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

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

Inputs

String[]

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.