Casper Imaging - Automated HD Wiping - Apple Script

GaToRAiD
Contributor II

So what I did here is create a applescript app that we run before we start imaging with casper imaging. I saved the file as an application thus it can run without applescript editor.

Sorry for my lack of commenting on what is done. See if you like it and maybe you might be able to offer some improvements.

do shell script "diskutil list | grep /dev"
set Drives to paragraphs of result

set FullList to do shell script "diskutil list | awk '{print $1 $3 $4}' | sed 's/#:NAMESIZE//g' | sed 's/[0-9]://g' | sed '/^$/d' | sed '/disk[0-9]/ i\

'" set selectedDrive to (choose from list Drives with prompt "" & FullList & " Which drive would you like to format? By default, you should format disk0" without multiple selections allowed) as text if selectedDrive is equal to "false" then display dialog "Exiting Program" error number -128 end if set SkynetRemoval to display dialog "Are you sure you want to format: " & selectedDrive buttons {"Yes", "No"} default button 2 set SkynetRemoval to returned of question Removal(selectedDrive, SkynetRemoval) display dialog "Drive: " & selectedDrive & " has been formated" on Removal(selectedDrive, SkynetRemoval) try if SkynetRemoval is equal to "Yes" then set Finished to do shell script "sudo diskutil partitionDisk " & selectedDrive & " 1 gpt jhfs+ "Macintosh HD" 100%" end if if SkynetRemoval is equal to "No" then display dialog "Almost destroyed the world....." end if on error do shell script "diskutil unmountDisk force " & selectedDrive do shell script "diskutil mountDisk " & selectedDrive end try end Removal

Enjoy!

2 REPLIES 2

bentoms
Release Candidate Programs Tester

Is this because your macs have different HD names? Or multiple HD's ?

GaToRAiD
Contributor II

Well, currently they have one HD, and we wanted a way to erase the HD which usually is file vaulted without going into disk utility. This the the answer. We just run it click the HD, then away it goes. Renamed to what we want and it's a lot quicker then going into disk utility to do the job.