Bulk update Departments/Buildings

Jason
Contributor II

I have a CSV with a list of all the departments and buildings. Is there an easy way to bulk import it into Jamf? I looked at MUT, but don't see how to do it with that. I think it can be done with the API as well, but if anyone has a working solution it would be helpful.

Thank you

7 REPLIES 7

yoopersteeze
New Contributor II

Hey @Jason,

Try giving these a shot. - Make Departments
- Make Buildings

Best of luck!

rustymyers
New Contributor II

I used https://pypi.org/project/python-jamf/ to create a small script to store current departments in a file and upload new ones. Let me know if you're interested in a cleaned up version of the code.

fgonzale
Contributor

@yoopersteeze those scripts you listed worked great. In particular I used the Make Departments one to import a list of about 450 departments.

I did have to make a change to that script/input file for a couple of things though.

In the script it requires a CSV file that has each new line separated by comma.

The script itself is then set to "nuke" the comma as it parses the CSV so that each entry in Jamf doesn't include it.

In my case I pulled the departments from our AD but some of these departments have commas in the actual department name...

So for my input CSV file instead I changed it to have each new line separated by colon.
Then in the script I changed line 62 from:

deptName=$(echo ${lines[i]} | sed 's/,//g' | tr -d '
')

to

deptName=$(echo ${lines[i]} | sed 's/://g' | tr -d '
')

That way instead of nuking the comma it nukes the colon and I am able to keep commas in my department names for those that have one.

As well, some department names had ampersand "&" and since this is writing to XML it won't parse correctly.

So in the input CSV file I escaped this by changing all the ampersand "&" to:

&

This will allow the use of ampersand "&" in department names (otherwise the script will error out for those entries).

Also, when manipulating the CSV file in Excel and saving as comma delimited for name entries that have commas it might want to wrap them in double quotes. If this happens the double quotes would actually show up in Jamf with the department name. So a text editor can be used to check the input CSV file for double quotes or other oddities.

Those script links are currently dead, do you have a copy of the script to share?

user-UYGhvrCopS
New Contributor

Thanks for the info i will try to figure it out for more

belldesean
New Contributor III

Use the Mut v5. It has a template that has about 15-20 different fields that you can populate at one time. https://apps.apple.com/us/app/mut/id1133234759?mt=12