我需要执行一个脚本来访问绑定到特定 IP 地址的网站。我在 C# 中找到了使用 BindIpEndPointDelegate 类来做到这一点的东西。
var req = (HttpWebRequest)WebRequest.Create("http://google.com/");
req.ServicePoint.BindIPEndPointDelegate = BindTo;
using (req.GetResponse());
static IPEndPoint BindTo(ServicePoint servicepoint, IPEndPoint remoteendpoint, int retrycount)
{
IPAddress ip = IPAddress.Any; //This is where you specify the network adapter's address
int port = 0; //This in most cases should stay 0. This when 0 will bind to any port available.
return new IPEndPoint(ip, port);
}
我不知道如何将该类传递给powershell。
感谢所有的帮助!