Posted on 07-02-2019 12:09 PM
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.
Posted on 07-02-2019 12:14 PM
echo "<result>$(diskutil info / | awk -F': ' '/File System/{print $NF}' | xargs)</result>"
Posted on 07-02-2019 12:47 PM
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'])
Posted on 07-03-2019 07:23 AM
Both scripts did the job. Thanks for your help!