Public/New-PrismOva.ps1

function New-PrismOva {
    <#
    .SYNOPSIS
        Creates an OVA.
 
    .DESCRIPTION
        Creates a new OVA. The OVA can be created from an existing VM, from a URL, or
        from an Objects Lite upload, as described by the supplied OVA specification.
 
    .NOTES
        Implements:
          POST /vmm/v{ApiVersion}/content/ovas (operationId: createOva)
 
        Uses the selected session's ApiVersion for the endpoint.
 
        The body must conform to the vmm.v4.2.content.Ova schema. At minimum 'name'
        and 'source' are required, and the source object must carry its '$objectType'
        discriminator (one of vmm.v4.content.OvaUrlSource, vmm.v4.content.OvaVmSource
        or an Objects Lite source).
 
    .PARAMETER PrismSession
        The server/FQDN of the PrismSession to use. May be omitted when only one session exists.
 
    .PARAMETER Ova
        The OVA specification (hashtable or object) to create.
 
    .EXAMPLE
        $spec = @{
            name = 'LinuxServer_2.1_OVA'
            source = @{
                '$objectType' = 'vmm.v4.2.content.OvaVmSource'
                vmExtId = 'ba8da8d6-4ee5-440d-8703-206051443ccc'
            }
            diskFormat = 'QCOW2'
        }
        New-PrismOva -Ova $spec
 
    .OUTPUTS
        A PrismTask reference describing the asynchronous create task.
    #>


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

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

    process {
        $name = $Ova.name ?? '<unnamed>'
        if (-not $PSCmdlet.ShouldProcess($name, 'Create OVA')) { return }

        $PrismSessionConfig = Get-PrismSession $PrismSession

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

        $RequestSplat = @{
            PrismSession = $PrismSession
            Method       = 'POST'
            Path         = ('vmm/v{0}/content/ovas' -f $PrismSessionConfig.ApiVersion)
            Header       = $headers
            Body         = $Ova
        }
        $Response = Invoke-PrismRequest @RequestSplat
        return [PrismTask]::new($Response.data, $PrismSessionConfig.Name)
    }
}