Posted on 12-11-2017 02:31 PM
Hopefully this will help someone.
At my current company they use Pulse Secure for VPN. The setup masks the IP locally so when you do a recon/inventory it doesn't actually pull the IP.
For support they have a website that the local user can go to and get the IP.
I wrote a script that curls the site and then uses the API to PUT the IP to the computer record based on serial number lookup so when a tech speaks to a user on VPN they can update the IP.
I have it PUT to both the IP and the Reported IP so the tech won't have to wait for the timeout on control of the computer on the Reported IP.
Obviously the parsing is specific to the site I'm pulling from and I'm basically a hack when it comes to scripting but you'll get the idea.
Not sure if there is an easier way but this is also a quick way to get the jssid with the API (bonus!)
jssUser="username"
jssPass="password"
jssUrl="https://companydomain.jamfcloud.com"
ipUrl="https://getmyip.companydomain.com"
serial_number=$(ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | sed '$s/"//'g)
jssid=$(/usr/bin/curl -sku $jssUser:$jssPass -H "Accept: application/xml" $jssUrl/JSSResource/computers/serialnumber/${serial_number}/subset/general -X GET | xpath //computer/general/id[1] 2>/dev/null | sed -e 's/<id>//' | sed -e 's/</id>//')
ipaddress=$(curl -s $ipUrl | grep "Your IP is" | sed '$ s/Your IP is //' | sed '$ s/.$//')
echo "$serial_number"
echo "$jssid"
echo "$ipaddress"
curl -X PUT -H "Accept: application/xml" -H "Content-type: application/xml" -k -u "${jssUser}":"${jssPass}" -d "<computer><general><ip_address>$ipaddress</ip_address></general></computer>" "${jssUrl}"/JSSResource/computers/id/"${jssid}";
sleep 1;
curl -X PUT -H "Accept: application/xml" -H "Content-type: application/xml" -k -u "${jssUser}":"${jssPass}" -d "<computer><general><last_reported_ip>$ipaddress</last_reported_ip></general></computer>" "${jssUrl}"/JSSResource/computers/id/"${jssid}";