I'm trying to write a batch script that will fetch the netconnectionid from wmin nic and then pass each of the returned values into a netsh command that will tell the interface to get it's IP from DHCP.
Here's what I have so far (non-operational)
@echo Off
For /f "tokens=2" %%a In ('wmic nic where "netconnectionid like '%%'" get netconnectionid /value') Do (
Call :dhcp "%%a %%b"
)
pause
exit
:dhcp
netsh interface ip set address %%b dhcp
The reason the script is needed instead of running commands for "Local Area Connection" or "Wireless Network Connection" is that this script will be ran on machines where the netconnectionid is no longer following the standard.
Being new to batch, I'm having issues deciphering the loop, and where exactly it's going wrong.