Public/Set-PrismOva.ps1

function Set-PrismOva {
    <#
    .SYNOPSIS
        Updates an OVA.
 
    .DESCRIPTION
        Updates the OVA with the given external identifier.
 
        This is a conditional operation: the v4 API requires the current ETag of the
        OVA (supplied as an If-Match header). This function first performs a GET
        to obtain a fresh ETag for each OVA.
 
    .NOTES
        Implements:
          PUT /vmm/v{ApiVersion}/content/ovas/{extId} (operationId: updateOvaById)
 
        Uses the selected session's ApiVersion for the endpoint.
 
        The body must conform to the vmm.v4.2.content.Ova schema.
 
    .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 update.
 
    .PARAMETER Ova
        The updated OVA specification (hashtable or object).
 
    .EXAMPLE
        $ova = (Get-PrismOva -ExtId $id).data
        $ova.name = 'RenamedOVA'
        Set-PrismOva -ExtId $id -Ova $ova
 
    .OUTPUTS
        A PrismTask reference describing the asynchronous update task.
    #>


    [CmdletBinding(SupportsShouldProcess = $true)]
    [OutputType([PrismTask])]
    param(
        [Parameter(Mandatory = $false,
            HelpMessage = 'Prism Session Name')][string]$PrismSession,

        [Parameter(Mandatory = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage = 'OVA external identifier (UUID)')]
        [Alias('Id', 'OvaExtId')][string]$ExtId,

        [Parameter(Mandatory = $true,
            ValueFromPipeline = $true,
            HelpMessage = 'Updated OVA specification')]
        [Alias('Body', 'Spec')][psobject]$Ova
    )

    process {
        if (-not $PSCmdlet.ShouldProcess($ExtId, 'Update OVA')) { return }

        $PrismSessionConfig = Get-PrismSession $PrismSession
        $ovaPath = 'vmm/v{0}/content/ovas/{1}' -f $PrismSessionConfig.ApiVersion, $ExtId

        $requestETag = Get-PrismResourceEtag -PrismSession $PrismSessionConfig.Name -Path $ovaPath

        $headers = @{
            'If-Match'        = $requestETag
            'NTNX-Request-Id' = (New-Guid).Guid
        }

        $RequestSplat = @{
            PrismSession = $PrismSession
            Method       = 'PUT'
            Path         = $ovaPath
            Header       = $headers
            Body         = $Ova
        }
        $Response = Invoke-PrismRequest @RequestSplat
        return [PrismTask]::new($Response.data, $PrismSessionConfig.Name)
    }
}