Private/ConfirmGoogleComputeVM.ps1

function ConfirmGoogleComputeVM {
    $GoogleComputeMetadataUrl = "http://metadata.google.internal/computeMetadata/v1/"
    
    try {
        #$Result = (Invoke-WebRequest -Uri $Url -UseBasicParsing -DisableKeepAlive -Method Head).StatusCode
        $HTTP_Request = [System.Net.WebRequest]::Create($GoogleComputeMetadataUrl)
        $HTTP_Response = $HTTP_Request.GetResponse()
        $Result = $HTTP_Response.StatusCode
    } catch [Net.WebException] {
        $Result = [int]$_.Exception.Response.StatusCode
    }

    if ($Result -eq 0) {
        $False
    }
    else {
        $True
    }
}