Import list of computers into Static Group?

donmontalvo
Esteemed Contributor III

We found a pocket of several hundred Macs in one of the environments we support. We want to get these Macs into JSS so we can get them into a Static Group. Is there a way to import a tab delimited or csv text file that contains only MAC Address, Serial Number and Computer Name? I'm hoping to avoid manually inputting these.

Thanks,
Don

--
https://donmontalvo.com
6 ACCEPTED SOLUTIONS

sean
Valued Contributor

Not a Casper user...yet (still pending), but is there a command line interface to Casper? If so, would it be possible to write a small script to populate it?

If not, I'm guessing that a CLI would be a very useful thing to add to the feature requests.

Sean

View solution in original post

jarednichols
Honored Contributor

Yeah, it's called mysql

;)

j

View solution in original post

talkingmoose
Moderator
Moderator

A few things:
On 5/23/10 9:41 AM, "Don Montalvo" <donmontalvo at gmail.com> wrote:

If SSH is enabled on the Macs and you have a local admin name/password for
each then you can use Casper Remote from one Mac to inventory an entire
network of Macs.

If SSH is not enabled then you probably want to run a Casper QuickAdd
package on each Mac to enable management of the machines. Yes, it requires
sneakernet and an admin to run the package on each machine, but without SSH
already enabled you don't have much choice.

Otherwise, if neither of these is possible then I can only assume you want
to import the spreadsheet simply to view it in the JSS without management of
the machines. Correct?

--

William Smith
Technical Analyst
Merrill Communications LLC
(651) 632-1492

View solution in original post

talkingmoose
Moderator
Moderator

You can deploy some sort of marker on each machine, such as a dummy package
or an ARD field, to identify them and put them into a smart group...

If they're all on the same network then you can create a smart group for
that even.

--

William Smith
Technical Analyst
Merrill Communications LLC
(651) 632-1492

View solution in original post

tlarkin
Honored Contributor

You can set up a prestage imaging part for those machines and image them and they will automatically pick up the auto run data for them. The best option to do in my opinion is, to ARD install the quick add pkg, then run some sort of post script for any custom inventory options. Plus once the casper ssh account is on there you can use the Jamf binary to do all sorts of things to help you organize them into groups. Naming convention, hardware type, so on and so forth

-Tom

View solution in original post

andrewseago
Contributor

I also posted this to my GitHub. I needed the same thing today. https://github.com/andrewseago/AndrewSeago---Scripts/blob/master/JSS%20API%20Scripts/jss_api_id_staticgroup.sh

View solution in original post

21 REPLIES 21

Not applicable

Dummy packages are always an option, but if you know these segregated
machines are going to be the only machines being added into your JSS for
the time being, you can just set up a smart group to pick out all
machines with a JSS ID greater than whatever your highest JSS ID
currently is.

Bob

donmontalvo
Esteemed Contributor III

Hi William,

We're not going to have a problem getting QuickAdd deployed to these computers. The department apparently have their own Mac guy supporting them. We need to get these computers into JSS so we can pull inventory (nothing else). So we want to isolate them in JSS. We want to do so before they call in to JSS so they're immediately segregated, and thus excluded from everything else in JSS.

I know I can manually add computers to JSS. Just thought JSS would be flexible enough to allow an import of a tab delimited file, or an Excel spreadsheet, etc. You know, the Mac guy's inventory list. :)

Don

--
https://donmontalvo.com

Not applicable

At the time it's not possible. Not from a tab-delimited or CSV anyway. I
asked JAMF this back when we were first starting to populate our JSS. I
wanted to pull a CSV from our Filemaker DB and populate Casper with it.
They told me there were just too many fields and too much room for error
on import/export.

The only way to do a mass import into Casper is either with the
quick-add package, or directly editing the SQL database. The latter,
obviously, is unsupported.

Bob

sean
Valued Contributor

Not a Casper user...yet (still pending), but is there a command line interface to Casper? If so, would it be possible to write a small script to populate it?

If not, I'm guessing that a CLI would be a very useful thing to add to the feature requests.

Sean

jarednichols
Honored Contributor

Yeah, it's called mysql

;)

j

donmontalvo
Esteemed Contributor III

(Dang Jared, you responded so fast! :)

We wanted to avoid manipulating the MySQL database (or anything not fully supported by JAMF). I guess we'll be manually entering 700 computers into JSS. Um....intern!!!! ;)

JAMF FEATURE REQUEST: Ability to pre-populate JSS by importing tab delimited (etc) file...

Don

--
https://donmontalvo.com

talkingmoose
Moderator
Moderator

A few things:
On 5/23/10 9:41 AM, "Don Montalvo" <donmontalvo at gmail.com> wrote:

If SSH is enabled on the Macs and you have a local admin name/password for
each then you can use Casper Remote from one Mac to inventory an entire
network of Macs.

If SSH is not enabled then you probably want to run a Casper QuickAdd
package on each Mac to enable management of the machines. Yes, it requires
sneakernet and an admin to run the package on each machine, but without SSH
already enabled you don't have much choice.

Otherwise, if neither of these is possible then I can only assume you want
to import the spreadsheet simply to view it in the JSS without management of
the machines. Correct?

--

William Smith
Technical Analyst
Merrill Communications LLC
(651) 632-1492

Not applicable

There is also the Apple Remote Desktop Approach. If these machines have ARD
you can deploy the QuickAdd to them this way.

Jon

Jonathan H. Smith | Sr. Systems Engineer | Genentech Informatics| office:
650-225-4968| mobile: 650-302-6985 | smith.jonathan at gene.com |

donmontalvo
Esteemed Contributor III

Hi Jonathan,

The problem is not getting QuickAdd out to computers. The problem is setting up JSS so when these computers 'call home', they're immediately put into a segregated exclusion group. No way to pre- populate JSS by importing a list...appears it has to be done manually. Good thing it's *only* several hundred Macs. :(

Thanks,
Don

--
https://donmontalvo.com

talkingmoose
Moderator
Moderator

You can deploy some sort of marker on each machine, such as a dummy package
or an ARD field, to identify them and put them into a smart group...

If they're all on the same network then you can create a smart group for
that even.

--

William Smith
Technical Analyst
Merrill Communications LLC
(651) 632-1492

tlarkin
Honored Contributor

You can set up a prestage imaging part for those machines and image them and they will automatically pick up the auto run data for them. The best option to do in my opinion is, to ARD install the quick add pkg, then run some sort of post script for any custom inventory options. Plus once the casper ssh account is on there you can use the Jamf binary to do all sorts of things to help you organize them into groups. Naming convention, hardware type, so on and so forth

-Tom

Not applicable

Have you thought of using a fake policy to create the static group?

I noticed that you can create a static group from the list of computers that
have not run a policy. So if you create a policy with an "Other" trigger and
set it for a frequency of once per computer, you could use this policy as a
collector of your newly found macs. Scope the policy for a unique department
or building.

Once the department or building is assigned via a QuickAdd package (or some
other method for reconning the computers) the computers will collect in the
new policy. When you have all of the computers collected, simply view status
on the collector policy and click 'Create Group'.

I not sure if that is what you are looking for, but it is what I would
attempt.

Regards,
Matt Haines

donmontalvo
Esteemed Contributor III

Drool....

http://twitter.com/JAMFSupport/status/362694545357545472

--
https://donmontalvo.com

andrewseago
Contributor

I also posted this to my GitHub. I needed the same thing today. https://github.com/andrewseago/AndrewSeago---Scripts/blob/master/JSS%20API%20Scripts/jss_api_id_staticgroup.sh

chris_kemp
Contributor III

niiice... :D

donmontalvo
Esteemed Contributor III

Dang @andrewseago, how many beers do JAMF Nation users owe you, so far? :D

--
https://donmontalvo.com

alexjdale
Valued Contributor III

Very nice, I have a similar bash script that takes in a text file list of hostnames and adds them to a static group via the API, but I've only had to use it twice so far so it's nowhere near that complete. It was not fun building the XML to post back up to the JSS.

andrewseago
Contributor

Yah rebuilding the XML was the tricky part. My next steps would be to build in the ability to retain existing systems in the group and just add to the group instead of a total membership update. I'm just hoping I don't have a reason to do that.

Pagigostra
New Contributor II
QuotedText

I know this post is old, but incase anyone still is looking for something. Let me know if you have any issues with this.

#!/bin/bash
# Options: 
# File: The script is set to take standard input for the file: ex. script /pathtofile/filename -> if no file is present it will exit script
# ->If the file name and location will always be the same you can make this a static variable
# SGID (Static Group ID): By default it is set to have a single Static Group ID, however  in the VARIABLES section you can change between User Input or Script Assigned SGID.
# Input line ex. /pathtoscript/script file SGID
#->I do not have a check built in to make sure that the SGID exists.

# API General Information
# To obtain the API token, run the following in terminal, replacing apiuser and apipassword
# with your API username and password
# printf "apiuser:apipassword" | iconv -t ISO-8859-1 | base64 -i -

# Variables #
JamfProURL=“URL GOES HERE“ # URL for Jamf Pro including HTTPS and port
APIToken=“INPUT YOUR TOKEN HERE” # see instructions above

# Getting the Input File
input_file="${1:-/dev/stdin}"
# Validating the file exists and is a regular file
if ! [ -f "$input_file" ]; then
        /bin/echo "No File was given"
        exit 1
fi

# You can change which of the following two is active
#StaticGroupID="${2:-/dev/stdin}"
StaticGroupID=“Desired ID”     # ID for static group to add device to

while read -r deviceSN; do
        /usr/bin/curl --header "authorization: Basic $APIToken" -H "Content-Type: text/xml" $JamfProURL/JSSResource/computergroups/id/$StaticGroupID -X PUT -d "<?xml version="1.0" encoding="ISO-8859-1"?><computer_group><id>$StaticGroupID</id><computer_additions><computer><serial_number>$deviceSN</serial_number></computer></computer_additions></computer_group>"
done < "$input_file"

exit 0

SIDE NOTE:

curl --header "authorization: Basic $APIToken" -H "Content-Type: text/xml" $JamfProURL/JSSResource/computergroups/id/$StaticGroupID -X PUT -d "<?xml version="1.0" encoding="ISO-8859-1"?><computer_group><id>$StaticGroupID</id><computer_deletions><computer><serial_number>$deviceSN</serial_number></computer></computer_deletions></computer_group>"

Can be used to remove a group of systems from a static group.

craigo
New Contributor III

Thanks for sharing @Pagigostra, that's a nice concise script doing exactly what I was looking for.
I did make some changes adding in the checks you mentioned for the 2nd parameter and allowed for user input if they don't exist.

#!/bin/bash

# Options: 
# input_file: Parameter 1 is an input for the file: ex. script /pathtofile/filename -> if no parameter is present you will be prompted for one
# The input_file should contain the serial numbers, one per line, of the computers to be added to the static group.
# staticGroupID: Parameter 2 is set to have a single Static Group ID -> if no parameter is present you will be prompted for one.

# API General Information
# To obtain the API token, run the following in terminal, replacing apiuser and apipassword
# with your API username and password
# printf "JamfUsername:JamfPassword" | iconv -t ISO-8859-1 | base64 -i -

# Variables #
# URL for Jamf Pro including HTTPS and port
jamfProURL="https://SOMETHING.jamfcloud.com"
# see instructions above
apiToken='SomethingInHere'

# Validating the file exists and is a regular file
if [ ! -f "$1" ]; then
    read -p "Path to input file: " input_file 
else
    # Getting the Input File
    input_file="${1:-/dev/stdin}"
fi

if [ -n "$2" ];then
    staticGroupID="${2:-/dev/stdin}"
else
    read -p "Static Group ID: " staticGroupID
fi


while read -r deviceSN
do
    /usr/bin/curl --header "authorization: Basic $apiToken" -H "Content-Type: text/xml" $jamfProURL/JSSResource/computergroups/id/$staticGroupID -X PUT -d "<?xml version="1.0" encoding="ISO-8859-1"?><computer_group><id>$staticGroupID</id><computer_additions><computer><serial_number>$deviceSN</serial_number></computer></computer_additions></computer_group>"
done < "$input_file"

exit 0

Cheers

mjgadient
New Contributor II

Is anyone getting the same error below?

 

 

   <title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Bad Request</p>
<p>Error in XML file</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>
<html>
<head>