Reference article: https://technet.microsoft.com/en-us/library/dn372891%28v=wps.630%29.aspx

Works only with: Windows Server 2012 R2 and Windows 8.1 or greater

example:

$server = “10.12.12.1”

Test-NetConnection -ComputerName $Server -Port 80 -InformationLevel Detailed -ErrorAction SilentlyContinue

Test-NetConnection -ComputerName $Server -Port 443 -InformationLevel Detailed -ErrorAction SilentlyContinue