Posted on 01-02-2018 12:35 PM
Hello,
I am new to the Mac and Jamf world and am in need of some advice. I need to deploy a script via Policy to change the "DisconnectOnLogout" value for each NIC on a device to "NO". The below AppleScript works but it prompts for credentials. How could I change this so that it runs silently?
Any assistance would be greatly appreciated!
activate application "Terminal"
tell application "System Events" to keystroke "sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport en0 prefs DisconnectOnLogout=NO"
tell application "System Events" to keystroke return
delay 2
tell application "System Events" to keystroke "sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport en3 prefs DisconnectOnLogout=NO"
tell application "System Events" to keystroke return
delay 2
tell application "Terminal"
quit
end tell
Solved! Go to Solution.
Posted on 01-02-2018 12:43 PM
There's no need for the Applescript portion of this. The command you have within that whole script can be deployed to managed Macs directly from Jamf Pro as is and it should work
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport en0 prefs DisconnectOnLogout=NO
I should note however that hardcoding in the en0
for the wireless port could run into some problems if you happen to have some older Macs that still have hard Ethernet ports in them, since wireless is then en1, not en0. It's best to determine what the Wi-Fi hardware port is within the script and use that as a placeholder or variable.
#!/bin/bash
WIFIPORT=$(/usr/sbin/networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport $WIFIPORT prefs DisconnectOnLogout=NO
Posted on 01-02-2018 12:43 PM
There's no need for the Applescript portion of this. The command you have within that whole script can be deployed to managed Macs directly from Jamf Pro as is and it should work
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport en0 prefs DisconnectOnLogout=NO
I should note however that hardcoding in the en0
for the wireless port could run into some problems if you happen to have some older Macs that still have hard Ethernet ports in them, since wireless is then en1, not en0. It's best to determine what the Wi-Fi hardware port is within the script and use that as a placeholder or variable.
#!/bin/bash
WIFIPORT=$(/usr/sbin/networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport $WIFIPORT prefs DisconnectOnLogout=NO
Posted on 01-02-2018 01:13 PM
That's easier than I thought - thank you! We want to change this setting for all NIC's, can that be done with a "for each" type loop?
Posted on 01-02-2018 01:27 PM
I'm confused. Are you saying your systems have multiple wireless ports? If so, I suppose you could use a loop like that to get and adjust them all. But as far as I know, the airport binary in that Apple802.11.framework only works on the wireless hardware devices. By "all NICs", if you mean for things like dongle Ethernets also, then you can't direct the command at those ports. It won't affect them unless they are specifically wireless ports.
Posted on 01-02-2018 01:42 PM
Got it - thank you very much!