Public/Remove-PrismOva.ps1
|
function Remove-PrismOva { <# .SYNOPSIS Deletes an OVA. .DESCRIPTION Deletes the OVA with the given external identifier. .NOTES Implements: DELETE /vmm/v{ApiVersion}/content/ovas/{extId} (operationId: deleteOvaById) Uses the selected session's ApiVersion for the endpoint. .PARAMETER PrismSession The server/FQDN of the PrismSession to use. May be omitted when only one session exists. .PARAMETER ExtId The external identifier (UUID) of the OVA to delete. .EXAMPLE Remove-PrismOva -ExtId '4c41eafe-82cc-44b3-93ff-cb5c6cf40150' .OUTPUTS A PrismTask reference describing the asynchronous delete task. #> [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] [OutputType([PrismTask])] param( [Parameter(Mandatory = $false, HelpMessage = 'Prism Session Name')][string]$PrismSession, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = 'OVA external identifier (UUID)')] [Alias('Id', 'OvaExtId')][string]$ExtId ) process { if (-not $PSCmdlet.ShouldProcess($ExtId, 'Delete OVA')) { return } $PrismSessionConfig = Get-PrismSession $PrismSession $headers = @{ 'NTNX-Request-Id' = (New-Guid).Guid } $RequestSplat = @{ PrismSession = $PrismSession Method = 'DELETE' Path = ('vmm/v{0}/content/ovas/{1}' -f $PrismSessionConfig.ApiVersion, $ExtId) Header = $headers } $Response = Invoke-PrismRequest @RequestSplat return [PrismTask]::new($Response.data, $PrismSessionConfig.Name) } } |