I am writing a script in a WinPE environment where I want to find my PXE server and send it my MAC address to retrieve provisioning scripts.
Here's what I have to deal with:
- The server will have multiple network adapters. Only one is connected to my PXE server.
- The PXE server is always also the DHCP server on that network.
- There may be other DHCP servers connected to the other NICs.
- The PXE server is also listening on port 80.
- cURL is available in the WinPE image.
I want the final line in the script to be:
curl -s -o %TEMP%/setup.cmd http://%PXE_IP%/cblr/svc/op/script/system/%MY_MAC%/?script=setup.cmd
I see that I get all the necessary info from ipconfig /all
but I have no idea how to parse that output.
For example I can do
for /f "tokens=15 delims= " %%X in ('ipconfig /all ^| find "DHCP Server"') do echo %%X
This gives me the IP addresses for the DHCP servers on each adapter. I can determine which is correct. But then what? I need the corresponding MAC address for that adapter. That information is in the output, but I threw it away with my find
.