I got this to work. Here is the code so if someone like me comes along they do not have to reinvent the wheel.
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$password = Read-Host -AsSecureString -Prompt "Password"
$NTNXCred = New-Object System.Management.Automation.PsCredential("Username",$password)
$RESTAPIUser = $NTNXCred.UserName
$RESTAPIPassword = $NTNXCred.GetNetworkCredential().Password
$Header = @{
"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($RESTAPIUser+":"+$RESTAPIPassword ))}
$Header.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri 'https://CVMIP:9440/PrismGateway/services/rest/v2.0/vms/' -Method POST -Headers $Header -ContentType 'application/json' -Body '{"allow_live_migrate":true,"boot":{"secure_boot":true,"uefi_boot":true},"name":"UEFITest","memory_mb":2048,"num_vcpus":2}' -UseBasicParsing