Invoke-WebRequest to use different NIC

Hi all, I have a problem that I need to use different Public IP address to fetch data from the same source. There is a quota that limits automation for x requests per day per IP address. I have configured an Azure virtual machine with two Public IP addresses, but can’t find a piece of clear information on how to route Invoke-WebRequest to use different ifIndex/InterfaceAlias. Is it possible or should I just create two different virtual machines for this case?

ifIndex interfacealias ConnectionState

 19 Ethernet 3           Connected
 15 Ethernet 2           Connected

Thanks in advance!

Is it feasible in your code to disable one interface, then enable when done?

You can set static routes, such as traffic to IP x.y.z uses interface 2. Not really a powershell thing though.

1 Like