On a windows system, I'm trying to gather all the IP addresses for a DNS name & call a tool with each IP address. I know how to do it from a shell script - but not how to do it from a batch or powershell file.
I want to port this to windows..
#!/usr/bin/env bash
# Get all the IPs for our server instance
# and pass it to "p4 trust" to update the .p4trust file
for address in $(dig perforce.example.com +short)
do
echo "processing address: $address:1666"
p4 -p "ssl:$address:1666" trust -y -f || true
done
Questions:
- is there a pre-installed windows
dig
equivalent that will only return the IPs of the DNS record? - in a batch or powershell file, how do you iterate over multiple results from another application?