Extension Attribute to list File System

SFRANCIS004
New Contributor III

I tried to create an Extension Attribute to list the Filesystem of each computer in the JSS.

I know the general command is diskutil info / | grep "Type (Bundle)" but don't know how to get the result to list in an inventory search.

Any help is appreciated.

3 REPLIES 3

tomhastings
Contributor II

!/bin/sh

echo "<result>$(diskutil info / | awk -F': ' '/File System/{print $NF}' | xargs)</result>"

tlarkin
Honored Contributor

Using diskutil will give you various results across models and different hardware configurations. The only true way to get it, is to just probe system_profiler, which is a slow as far as binaries go, but it is one of the few ways to always get guaranteed results.

#!/usr/bin/python

import subprocess
import plistlib

cmd = ['system_profiler', 'SPStorageDataType', '-xml']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = proc.communicate()
data = plistlib.readPlistFromString(out)[0]['_items']
print(data[0]['file_system'])

SFRANCIS004
New Contributor III

Both scripts did the job. Thanks for your help!