If the Proxy does not exist, you can easily check the connection by specifying the 80 or 443 port with the Test-NetConnection command, but if the Proxy exists, you cannot use this method with Test-NetConnection. Because Test-NetConnection cannot specify a proxy.
A command that can be used in this case is the Invoke-WebRequest command.
The following is an example of confirming the connection to this site (https://en.win2012r2.com) with the command. Since the StatusCode is 200, we know that communication was successful.
PS > Invoke-WebRequest -URI https://en.win2012r2.com
StatusCode : 200
StatusDescription : OK
Content : <!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit...
<Omit>
The following is an example of execution when connecting to this site via a proxy.
PS > Invoke-WebRequest -URI https://en.win2012r2.com -Proxy http://proxy.test.local:8080
StatusCode : 200
StatusDescription : OK
Content : <!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit...
<Omit>
Comments