Save-GitHubReleaseAsset¶
SYNOPSIS¶
Downloads a GitHub Release asset.
SYNTAX¶
By Asset ID (Default)¶
Save-GitHubReleaseAsset -Owner <String> -Repository <String> -ID <String> [-Path <String>] [-Expand] [-Force]
[-PassThru] [-Context <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
By Tag and Asset Name¶
Save-GitHubReleaseAsset -Owner <String> -Repository <String> -Tag <String> -Name <String> [-Path <String>]
[-Expand] [-Force] [-PassThru] [-Context <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
By Release ID and Asset Name¶
Save-GitHubReleaseAsset -Owner <String> -Repository <String> -ReleaseID <String> -Name <String>
[-Path <String>] [-Expand] [-Force] [-PassThru] [-Context <Object>] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
By Asset Object¶
Save-GitHubReleaseAsset -ReleaseAssetObject <GitHubReleaseAsset> [-Path <String>] [-Expand] [-Force]
[-PassThru] [-Context <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
DESCRIPTION¶
Downloads an asset from a repository release.
The asset is downloaded as a file to the specified path
or the current directory by default.
Users must have read access to the repository.
For private repositories,
personal access tokens (classic) or OAuth tokens with the repo
scope are required.
EXAMPLES¶
EXAMPLE 1¶
Save-GitHubReleaseAsset -Owner 'octocat' -Repository 'Hello-World' -ID '123456' -Path 'C:\Assets'
Output:
Directory: C:\Assets
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 03/31/2025 12:00 4194304 asset-123456.zip
Downloads release asset ID '123456' from the 'Hello-World' repository owned by 'octocat' to the specified path.
EXAMPLE 2¶
Save-GitHubReleaseAsset -Owner 'octocat' -Repository 'Hello-World' -Tag 'v1.0.0' -Name 'binary.zip' -Path 'C:\Assets\app' -Expand -Force
Output:
Directory: C:\Assets\app
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 03/31/2025 12:00 5120 config.json
-a---- 03/31/2025 12:00 4194304 application.exe
Downloads asset named 'binary.zip' from the release tagged as 'v1.0.0' in the 'Hello-World' repository owned by 'octocat' to the specified path, overwriting existing files during download and extraction.
EXAMPLE 3¶
$params = @{
Owner = 'octocat'
Repository = 'Hello-World'
ID = '123456'
Tag = 'v1.0.0'
Name = 'binary.zip'
}
Get-GitHubReleaseAsset @params | Save-GitHubReleaseAsset -Path 'C:\Assets' -Expand -Force
Pipes a release asset object directly to the Save-GitHubReleaseAsset function, which downloads and extracts it.
PARAMETERS¶
-Owner¶
The account owner of the repository. The name is not case sensitive.
Type: String
Parameter Sets: By Asset ID, By Tag and Asset Name, By Release ID and Asset Name
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Repository¶
The name of the repository without the .git extension. The name is not case sensitive.
Type: String
Parameter Sets: By Asset ID, By Tag and Asset Name, By Release ID and Asset Name
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-ID¶
The unique identifier of the asset.
Type: String
Parameter Sets: By Asset ID
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-ReleaseID¶
The unique identifier of the release.
Type: String
Parameter Sets: By Release ID and Asset Name
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Tag¶
The tag name of the release.
Type: String
Parameter Sets: By Tag and Asset Name
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Name¶
The name of the asset to download.
Type: String
Parameter Sets: By Tag and Asset Name, By Release ID and Asset Name
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ReleaseAssetObject¶
The GitHubReleaseAsset object containing the information about the asset to download.
Type: GitHubReleaseAsset
Parameter Sets: By Asset Object
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-Path¶
Path to the file or folder for the download. Accepts relative or absolute paths.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $PWD.Path
Accept pipeline input: False
Accept wildcard characters: False
-Expand¶
When specified, the ZIP file is extracted to the same directory it was downloaded to.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: Extract
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Force¶
When specified, overwrites existing files during download and extraction.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-PassThru¶
When specified, the downloaded file or the folder where the ZIP file was extracted to is returned.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Context¶
The context to run the command in. Used to get the details for the API call. Can be either a string or a GitHubContext object.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-GitHubContext)
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
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¶
GitHubReleaseAsset¶
OUTPUTS¶
System.IO.FileSystemInfo[]¶
NOTES¶
Contains the extracted file or folder information from the downloaded asset. This output can include directories or files depending on the asset content.
RELATED LINKS¶
https://psmodule.io/GitHub/Functions/Releases/Assets/Save-GitHubReleaseAsset/