Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Created August 3, 2020 03:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talkingmoose/fd9db85f00a53183de62278a784e0fb5 to your computer and use it in GitHub Desktop.
Save talkingmoose/fd9db85f00a53183de62278a784e0fb5 to your computer and use it in GitHub Desktop.
Compares known and current network services and creates an unknown network services list.
#!/bin/zsh
# list of known network services that should be excluded from results
defaultNetworkServices="An asterisk (*) denotes that a network service is disabled.
USB-C Dock Ethernet
Apple USB Ethernet Adapter
Wi-Fi
iPhone USB
Bluetooth PAN
Thunderbolt Bridge"
# create list of current network services
currentNetworkServices=$( /usr/sbin/networksetup -listallnetworkservices )
# create list of unknown network services
while IFS= read aService
do
if [[ "$defaultNetworkServices" != *"$aService"* ]]; then
serviceList="$aService
$serviceList"
fi
done <<< "$currentNetworkServices"
# return list to Jamf Pro
echo "<result>${serviceList%?}</result>"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment