Skip to main content
Question

Follow up from JAMF event in Cupertino 4/1/14 Ascript that removes machines from the JSS.

  • April 1, 2014
  • 9 replies
  • 56 views

Forum|alt.badge.img+16

There was a request for a copy of an script that removes machines from the JSS. This script will also erase/formate the drive, watch out : )

#!/bin/csh

set UUID=`diskutil cs info disk0s2|grep LVG |awk '{ print $4; }'`

echo "$UUID"

diskutil cs delete $UUID


diskutil partitionDisk disk0 GPT JHFS+ Macintosh HD 100%


set CAM=`networksetup -getmacaddress en1 | cut -c18-35 |sed 's/:/./g'`

curl -k -v -u xusernamex:xpasswordx https://yourjss.juniper.net:8443/JSSResource/computers/macaddress/$CAM -X DELETE



set JAM=`networksetup -getmacaddress en0 | cut -c18-35 |sed 's/:/./g'`

curl -k -v -u xusernamex:xpasswordx https://yourjss.juniper.net:8443/JSSResource/computers/macaddress/$JAM -X DELETE

echo
ioreg -c "IOPlatformExpertDevice" | awk -F '"' '/IOPlatformSerialNumber/ {print $4}'
echo

9 replies

Forum|alt.badge.img+9
  • Contributor
  • April 1, 2014

Enjoyed hearing about the things you are doing over at Juniper. You actually answered an issue that I had banged my head against the wall so much that I had put it on the back burner, so thanks for that. :)


Forum|alt.badge.img+16
  • Author
  • Honored Contributor
  • April 2, 2014

Thank you very much Noah,

I was worried that I was all over the place : )

C


jhbush
Forum|alt.badge.img+27
  • Esteemed Contributor
  • April 2, 2014

@gachowski would you be able to post the slides to the MacBrained Facebook group?


Forum|alt.badge.img+12
  • Contributor
  • April 2, 2014
diskutil cs info disk0s2 | awk '/LVG/{ print $4 }'

;D


Forum|alt.badge.img+16
  • Author
  • Honored Contributor
  • April 2, 2014

Jason,

I am not sure, that just the slides would make sense, I was in and out of our jss and there was a lot of me "running at the mouth" ..... : )

I will think about, how to get the info posted, but it might take some time and not sure if I can : )

C


Chris_Hafner
Forum|alt.badge.img+27
  • Jamf Heroes
  • April 4, 2014

Someone help me out here. I'm not, as of yet, a script master of any kind. If I were to remove the following lines, would that stop the formatting of the drive while carrying out the other intended functions (namely, the removal of said computer record from the database?)

set UUID=diskutil cs info disk0s2|grep LVG |awk '{ print $4; }' echo "$UUID" diskutil cs delete $UUID diskutil partitionDisk disk0 GPT JHFS+ Macintosh HD 100%

Forum|alt.badge.img+16
  • Author
  • Honored Contributor
  • May 20, 2014

@ Chris, I bet you know this by now sorry : ) yep : )

Here is the script for Casper 9.0.3 ( I would guess that it works on all 9.X

#!/bin/csh
## It has to be a csh script
# getting UUID
set UUID=`ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, """); printf("%s
", line[4]); }'`

# deleting computer from casper with UUID
curl -k -v -u username:password https://yourjss.com:8443/JSSResource/computers/udid/$UUID -X DELETE

Chris_Hafner
Forum|alt.badge.img+27
  • Jamf Heroes
  • May 20, 2014

Fantastic and thanks! I ended up using the hardware address based calling you had posted earlier. It's been fantastic! I hadn't thought to move in this direction before I came across your post and it's like a small light opened up in my brain showing the various possibilities. I need to spend some time really focusing on shell scripting so I can start coming up with this stuff on my own ;-) I now have a whole new line of thinking to pursue!


Chris_Hafner
Forum|alt.badge.img+27
  • Jamf Heroes
  • May 20, 2014

I'll have to jump back in here later. Just for fun I tried that new script out and it didn't just work magically. That said, I'm going to test this out next week once I've got some time again. I just wanted to post this in case anyone else just grabbed it. Using the previously mentioned:

#!/bin/csh
set CAM=`networksetup -getmacaddress en1 | cut -c18-35 |sed 's/:/./g'`

curl -k -v -u xusernamex:xpasswordx https://yourjss.juniper.net:8443/JSSResource/computers/macaddress/$CAM -X DELETE

set JAM=`networksetup -getmacaddress en0 | cut -c18-35 |sed 's/:/./g'`

curl -k -v -u xusernamex:xpasswordx https://yourjss.juniper.net:8443/JSSResource/computers/macaddress/$JAM -X DELETE

works just fine at the moment.