Spruce can also do cleanup of computers (and other things, like policies) fwiw.
This is resolved in Jamf Pro 10.6 as referenced in the Beta Release Notes.
@scafide thanks for confirming...can't wait for 10.6.1. ;)
I have a post on how I'm doing mass-deletion via the API:
https://derflounder.wordpress.com/2018/05/19/using-the-jamf-pro-api-to-mass-delete-computers-and-mobile-devices/
That said, I'm very happy to hear this is fixed in 10.6.x.
@rtrouton thanks, Jamf Support told us Product Issue PI-004957 impacts both GUI and API mass deletion.
Sure, which is why my solution is deleting one ID at a time, which doesn't run afoul of PI-004957
.
Hey guys, mine is working but I had to wait about 20minutes for it to process.
@rtrouton ah...I should have RTFB (Read The Fine Blog). :) My apologies, I assumed wrongly. Will test your script today. Thanks!
We ended up taking parts of @rtrouton's script and some other scripts found here on Jamf Nation and tweaking for our needs.
Basically save a report with the computers you want to delete, and with only JSS ID checked, then put it in a folder with our script, and let it rip. After script finishes, run the report again to confirm it shows zero computers.
DISCLAIMER: We hard code the URL to avoid any mistakes, this way we can give a walk through pointing to our QA before running in Production.
#!/bin/bash
currentDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
reportFile="$1"
tempFile="/tmp/tempFile.csv"
inputFile="${currentDir}/inputFile.csv"
jamfproURL="https://server.domain.com:8443"
jamfproIDURL="${jamfproURL}/JSSResource/computers/id"
jamfproURL=${jamfproURL%%/}
# cd to working folder
cd "$currentDir"
# Remove header
sed '1d' "${reportFile}" > ${tempFile}
# Trim list to just JSS ID numbers
cat ${tempFile} | cut -f2 -d"," > ${inputFile}
# Ensure csv has a line return at end of file
if [[ -n "$(tail -c 1 "${inputFile}")" ]]
then
sed -i '' -e "'$a'" "${inputFile}"
fi
# Prompt for credentials
if [[ -n ${inputFile} && -r ${inputFile} ]]; then
echo ""
echo "Enter username:"
read apiUser
echo ""
echo "Enter password:"
read apiPass
echo ""
# Loop through list to remove JSS IDs from JSS
while read -r ID
do
if [[ "$ID" =~ ^[0-9]+$ ]]; then
curl -X DELETE "${jamfproIDURL}/$ID" -u ${apiUser}:${apiPass}
else
echo "Sorry every line in file needs to be a number!"
fi
done < ${inputFile}
else
# Complain if the list is missing or wrong format.
echo "Input file is missing or not the right format. Contact Mac Engineering."
ERROR=1
fi
exit 0
At some point I plan to try to clean up (or simplify) the output of success and error.
Currently here is what you get if you have a list of 3 computers that exist:
<?xml version="1.0" encoding="UTF-8"?><computer><id>10100</id></computer><?xml version="1.0" encoding="UTF-8"?><computer><id>10101</id></computer><?xml version="1.0" encoding="UTF-8"?><computer><id>10102</id></computer>
And here is what you get if you have a list of 3 computers that do not exist:
<html>
<head>
<title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Not Found</p>
<p>The server has not found anything matching the request URI</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>
<html>
<head>
<title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Not Found</p>
<p>The server has not found anything matching the request URI</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>
<html>
<head>
<title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Not Found</p>
<p>The server has not found anything matching the request URI</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>
HTH,
Don