Skip to main content
Solved

Inventory report: External Hard Drive

  • October 24, 2017
  • 9 replies
  • 35 views

Forum|alt.badge.img+4

Is there any way to search in JAMF or create some sort of inventory report that can identify computers that have external hard drives attached? We'd like to be able to identify which of our users are using external drives and whether or not those drives are encrypted.

Best answer by todd_mcdaniel

I think this will accomplish what you've described.

Create an extension attribute, use this as the script. Then create a smart group containing non-blank content for that EA.

Let me know if it doesn't quite work for you.

#!/usr/bin/python

# Copyright (c) 2017 University of Utah Student Computing Labs. ################
# All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appears in all copies and
# that both that copyright notice and this permission notice appear
# in supporting documentation, and that the name of The University
# of Utah not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission. This software is supplied as is without expressed or
# implied warranties of any kind.
################################################################################

# ea_external_encrypted_disks.py ###############################################
#
# A Python script report external disks and encryption status.
#
#    1.0.0  2017.10.24      Initial release. tm
#
################################################################################

# Notes ########################################################################
#   Example output:
#       <result>3 external drives. 1 encrypted.</result>
#
#   Offline encrypted (ejected, but still attached) drives will cause odd results.
#   Checking for physical and external is probably overkill...
#   An encrypted internal volume will be included in encrypted count. Doh.
#
################################################################################

from __future__ import print_function
import subprocess

raw_disklist = subprocess.check_output(["/usr/sbin/diskutil", "list"])
raw_disklist = raw_disklist.split("
")

external_disks = 0
encrypted_disks = 0

for item in raw_disklist:
    if "/dev/disk" in item and "physical" in item and "external" in item:
        external_disks += 1
    elif "Encrypted" in item:
        encrypted_disks += 1

if external_disks >= 2:
    print("<result>" + str(external_disks) + " external drives. " + str(encrypted_disks) + " encrypted.</result>")
elif external_disks:
    print("<result>External Drive Present. " + str(encrypted_disks) + " encrypted.</result>")

9 replies

Forum|alt.badge.img+9
  • Contributor
  • Answer
  • October 24, 2017

I think this will accomplish what you've described.

Create an extension attribute, use this as the script. Then create a smart group containing non-blank content for that EA.

Let me know if it doesn't quite work for you.

#!/usr/bin/python

# Copyright (c) 2017 University of Utah Student Computing Labs. ################
# All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appears in all copies and
# that both that copyright notice and this permission notice appear
# in supporting documentation, and that the name of The University
# of Utah not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission. This software is supplied as is without expressed or
# implied warranties of any kind.
################################################################################

# ea_external_encrypted_disks.py ###############################################
#
# A Python script report external disks and encryption status.
#
#    1.0.0  2017.10.24      Initial release. tm
#
################################################################################

# Notes ########################################################################
#   Example output:
#       <result>3 external drives. 1 encrypted.</result>
#
#   Offline encrypted (ejected, but still attached) drives will cause odd results.
#   Checking for physical and external is probably overkill...
#   An encrypted internal volume will be included in encrypted count. Doh.
#
################################################################################

from __future__ import print_function
import subprocess

raw_disklist = subprocess.check_output(["/usr/sbin/diskutil", "list"])
raw_disklist = raw_disklist.split("
")

external_disks = 0
encrypted_disks = 0

for item in raw_disklist:
    if "/dev/disk" in item and "physical" in item and "external" in item:
        external_disks += 1
    elif "Encrypted" in item:
        encrypted_disks += 1

if external_disks >= 2:
    print("<result>" + str(external_disks) + " external drives. " + str(encrypted_disks) + " encrypted.</result>")
elif external_disks:
    print("<result>External Drive Present. " + str(encrypted_disks) + " encrypted.</result>")

Forum|alt.badge.img+4
  • Author
  • Contributor
  • October 25, 2017

Thank you for the suggestion. I'll give this a shot. Using external attributes is new to me, however, so what would you suggest for the Smart Group criteria?

At the moment, I've created a smart group based on this EA that is "like external" (since it appears the script would output "external" if one is present). Am I on the right path, or did I misunderstand how to go about this?


Forum|alt.badge.img+9
  • Contributor
  • October 25, 2017

Since the EA won't return anything if there are no external disks, I would use:

YOUR_EA_NAME [is not] [ "leave blank" ]


Forum|alt.badge.img+4
  • Author
  • Contributor
  • October 26, 2017

This works great! HUGE thank you!


Forum|alt.badge.img+5
  • Contributor
  • May 1, 2019

This is awesome I am trying this out today.

@todd.mcdaniel do you have a github we can reference? I'd like to fork it over to my account. If not are you okay with me adding this script to my github?


Forum|alt.badge.img+9

Thank you for your interest and I'm glad you can make use of it.

This script is included in this repo: SCL JAMF Pro Extension Attribute Collection.


Forum|alt.badge.img+5
  • Contributor
  • May 1, 2019

Awesome!!! Thanks for the Github link!!!


Forum|alt.badge.img+5
  • Contributor
  • September 19, 2019

Will this also count DMGs?


Forum|alt.badge.img+9
  • Contributor
  • January 31, 2020

@a.holley I believe "Physical" and "External" will exclude mounted disk images.