JSS API - Delete command

sgoetz
Contributor

Hey Nation!

Im looking into writing a script that will delete computers from JSS as an employee gets term and the laptop is returned to inventory. The command I have so far and seems to work, but I wanted to get your guys opinions on this, is as follows:

curl -X DELETE -u username:password https://jss.url.com:8443/JSSResource/computers/id/computerID

Thank you!

7 REPLIES 7

gachowski
Valued Contributor II

That looks about right : )

Here is the thread I started about it..

https://jamfnation.jamfsoftware.com/discussion.html?id=10188

C

sgoetz
Contributor

@gachowski Thank you!! That post actually helped out a lot!!

krispayne
Contributor

here's a bash script that will take a CSV and blast them away. I'm currently using this to remove machines from an old JSS while migrating to a new one. Read the comments I posted there, it's slow, abusive, and works. Kind of like Sean Connery? Dunno.

mm2270
Legendary Contributor II

@krispayne Just looked at your script. Hate to tell you this, but wget is not a native binary in OS X, or at least not up to 10.10, maybe its part of 10.11 now? You might have installed it at one point, but admins trying to run your script may encounter an error since it won't be able to find the binary. You may want to switch it to use curl which is included in the OS. For something like this, there's no real advantage I know of to use wget as opposed to curl. Curl will get the job done.

To be sure I'm not completely crazy, I ran the following commands on my Yosemite 10.10.5 Mac-

which wget

and...

sudo find / -name wget

Neither returned anything. Contrast this will using curl as an example:

sudo find / -name curl
/usr/bin/curl

krispayne
Contributor

Ack! Thanks, @mm2270 !

Only reason I'm using wget is to bypass the cert. We're using a JSS generated cert and I couldn't find the command in curl to bypass it. Always failed the handshake. If you happen to know that flag, I can definitely switch back to curl.

mm2270
Legendary Contributor II

@krispayne Does the -k flag in curl not do this? I'm not entirely sure, but I thought that allowed curl to bypass insecure connections due to something like self signed certificates.

From the curl manpage:

-k, --insecure (SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers. All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. This makes all connections considered "insecure" fail unless -k, --insecure is used.

krispayne
Contributor

@mm2270 I definitely tried -k but I will give it another shot and see