Run a search for clients not assigned a Site

mcrispin
Contributor II

Can this be done for either OS X or iOS clients? We have converted from "department" based organizational model to one based on Sites. I am sure I missed a few machines and have not yet assigned them to a Site. I don't see anything in display preferences, nor in extension attributes. Perhaps there is a way to parse with the 9.12 binary?

2 REPLIES 2

waderobson
New Contributor III

as far as I can tell you cannot search for machines without a site assigned. You could do the math to see if you missed any tho. Chose a site then list all machines, compare that to your "full jss number" and see if your off. I had a search in 8 that would list machines with building = "" . But that doesn't seem to be there for sites right now.

wyip
Contributor

You can get this info from the API. Here's an EA that pulls this info... you'll want to create an API account with read access in the JSS for this.

#!/bin/sh

apiURL='https://yourjss.com:8443/JSSResource/computers/udid/'
apiUser="*YourAPIuser*"
apiPass="*YourAPIusersPassword*"
udid=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Hardware UUID:/ { print $3 }')

siteName=$(/usr/bin/curl -H "Accept: application/xml" -s -u ${apiUser}:${apiPass} "${apiURL}${udid}" | /usr/bin/xpath '/computer/general/site/name[1]/text()' 2>/dev/null)

if [[ "$siteName" != "" ]]; then
    echo "<result>$siteName</result>"
else
    echo "<result>Not Available</result>"
fi
exit 0

This returns "None" if no site is assigned, the name of the site if one is assigned, and "Not Available" if this script doesn't get a value back from the API for some reason. All you need to do then is create a smart group based off of this.