Lets Talk JAMF/Casper

@willpolley Can you share with us the policy that you showed at the JAMF Admin about removing the public wifi from your preferred networks?

You can set up a script to run two lines. First, collect the relevant interfaces. Second, remove the SSID.

In the JSS, you’ll just have to pick your policy with a scope & then trigger it like normal (repeatedly if your users continuously add the wrong SSID).

#!/bin/sh
WirelessPort=$(networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')
networksetup -removepreferredwirelessnetwork $WirelessPort "NameOfSSID"

https://jamfnation.jamfsoftware.com/discussion.html?id=19092

2 Likes

That’s what I’m doing basically.

My policy is scoped to All Computers, Ongoing frequency, Weekly. At check-in and startup.

1 Like

I took it another step. After removing the guest network, the script checks to see if the computer is on the guest network and if it is it turns the wifi off then back on. (This is scoped for Staff laptops)

wservice=networksetup -listallnetworkservices | grep -Ei '(Wi-Fi|AirPort)'
device=networksetup -listallhardwareports | awk "/$wservice/,/Ethernet Address/" | awk 'NR==2' | cut -d " " -f 2
current=networksetup -getairportnetwork $device | cut -d " " -f 4
networksetup -removepreferredwirelessnetwork “$device” “Chapel_Guest”

if [ “$current” = “Chapel_Guest” ]; then
networksetup -setairportpower “$device” off
networksetup -setairportpower “$device” on
fi

2 Likes

If you use a management platform and take @Joem’s approach, be sure to throw in a while loop to check for connectivity after the WiFi power flip.

This will reduce the number of policy failures.

2 Likes

This is great! Thank you guys! Anyone going to JAMF Nation User Conference 2016?

I am!

But you probably already knew that…

1 Like