Functions/Public/Remove-GitHubReleaseAsset.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
function Remove-GitHubReleaseAsset { <# .SYNOPSIS Remove an asset from a release .DESCRIPTION Remove an asset from a release .PARAMETER Repository The name of the repository .PARAMETER Id The id of the asset .INPUTS System.String .OUTPUTS System.Management.Automation.PSObject .EXAMPLE Remove-GitHubReleaseAsset -Repository MyRepository -Id xxxx #> [CmdletBinding(SupportsShouldProcess,ConfirmImpact="High")][OutputType('System.Management.Automation.PSObject')] Param ( [Parameter(Mandatory=$true, Position=0)] [ValidateNotNullOrEmpty()] [String]$Repository, [Parameter(Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)] [ValidateNotNullOrEmpty()] [String[]]$Id ) Begin { # --- Grab the sessionstate variable & test throw if it is null $SessionInfo = Get-GitHubSessionInformation -Verbose:$VerbosePreference } Process { try { foreach ($AssetId in $Id) { if ($PSCmdlet.ShouldProcess($Id)){ Write-Verbose -Message "Removing asset $($AssetId)" $URI = "/repos/$($SessionInfo.Username)/$($Repository)/releases/assets/$($AssetId)" Invoke-GitHubRestMethod -Method DELETE -URI $URI -Verbose:$VerbosePreference } } } catch [Exception]{ throw $_.Exception } } End {} } |