Archive
Detecting Boot Camp partitions with Casper
I was recently tasked with reporting on how many Boot Camp installs of Windows we had on our Macs. Boot Camp is something we normally do on a as-needed basis, so it’s not on every machine. However, I did need something that worked consistently across the various flavors of OS X that we have.
In this case, I was asked to just verify the existence of a Boot Camp partition and was not tasked with identifying the version of Windows that was installed on the partition. With a little help from this thread on JAMF Nation, I was able to come up with the following script for use as a Casper Extension Attribute:
#!/bin/sh # # Using diskutil list to check for # disk partitions reporting as # "Microsoft Basic Data" # BOOTCAMP_DETECT=$( /usr/sbin/diskutil list | grep -c "Microsoft Basic Data" ) # # If Microsoft Basic Data partition is # reported by diskutil, script reports # "Yes". If no Microsoft Basic Data partition # is reported by diskutil, script reports "No". # if [[ "${BOOTCAMP_DETECT}" == "1" ]]; then result=Yes else result=No fi echo "<result>$result</result>" exit 0
This script uses the diskutil list command to check for disk partitions reporting as being Microsoft Basic Data. I chose not to look for NTFS volumes, as that could pick up false positives from non-Boot Camp NTFS drives.
If a Microsoft Basic Data partition is reported by diskutil, the script reports Yes. If there is not a Microsoft Basic Data partition on the Mac, the script reports No.
For those interested, the script is available on my GitHub repo:
Recent Comments