Hello, I am trying to create a Extension Attribute to show me which computers have a network called LP-Admin in their preferred network list. I found this script which will show all of their networks on a Macbook Air
networksetup -listpreferredwirelessnetworks en0
Not sure if that will be helpful for the script or not. I am completely new to scripting any help will be much appreciated.
Best answer by jesseshipley
It is pretty simple. You do an if statement where it looks to see if LP-Admin is in the resulting text of the command you mentioned. Extension attributes always look for whatever is between <result> and </result> so you echo the response for when it is true and for when it isn't. Hope this helps.
#!/bin/sh
if $(networksetup -listpreferredwirelessnetworks en0 | grep -q "LP-Admin"); then
echo '<result>TRUE</result>'
else
echo '<result>FALSE</result>'
fi
It is pretty simple. You do an if statement where it looks to see if LP-Admin is in the resulting text of the command you mentioned. Extension attributes always look for whatever is between <result> and </result> so you echo the response for when it is true and for when it isn't. Hope this helps.
#!/bin/sh
if $(networksetup -listpreferredwirelessnetworks en0 | grep -q "LP-Admin"); then
echo '<result>TRUE</result>'
else
echo '<result>FALSE</result>'
fi