Script to assign and remove arbitrary secondary IPs to an interface

I can't come up with a complete answer, but this may help put you in the right direction.

You could use netsh from PowerShell to dump the current configuration..

netsh interface ipv4 dump >C:\netsh.txt

This should give you something like this:

# ----------------------------------
# IPv4 Configuration
# ----------------------------------
pushd interface ipv4

reset
set global icmpredirects=enabled
add route prefix=0.0.0.0/0 interface="WAN" nexthop=192.168.1.1 publish=Yes
set subinterface interface= subinterface=ethernet_6 mtu=1492
add address name="WAN" address=192.168.1.200 mask=255.255.255.0
add address name="WAN" address=192.168.1.210 mask=255.255.255.0


popd
# End of IPv4 configuration

You can do 'grep' and 'sed'-like operations on the resulting text file, using the information here. This is the bit that I cannot detail without spending more time on it, because as you can see above, the lines for the addresses have an identical format. Your script will have to grep both the address lines to variables, and you will only sed the second variable.

You can then run the edited configuration script with..

netsh exec C:\netsh.txt

Note that ipconfig will show both new and old configuration data until you reboot, but it should appear correctly in the GUI, I think.