[System.Uri]$url = 'https://ateam01serversizes.azurewebsites.net/api/sizes/location/east/connectiontype/ams' $fqdn = $url.Host $port = '443' if (-not (Test-NetConnection -ComputerName $fqdn -Port $port -WarningAction 'SilentlyContinue' -ErrorAction 'Stop').TcpTestSucceeded) { throw "Missing access to $fqdn on tcp port $port. Stop" } try { Invoke-WebRequest -Uri $url -OutFile $jsonFile -UseBasicParsing } catch { $webClient = New-Object -TypeName 'System.Net.WebClient' $webClient.DownloadFile($url, $jsonFile) $webClient.Dispose() } if (-not (Test-Path -Path $jsonFile)) { throw "The file $jsonFile does not exist. Stop" } $jsonContent = ConvertFrom-Json -InputObject (Get-Content -Path $jsonFile) #$jsonContent.sizes try { $null = Connect-VIServer -Server $VCenter -User $VCUsername -Password $VCUserPassword -ErrorAction 'Stop' } catch { throw "Could not connect to VMware vCenter $VCenter. Stop" }