Hi @tep Your xml file is malformed. The </computers> tag near the end actually needs to be written as <computers/> because you aren't specifying any actual computers in that group, which of course makes sense since you want it to populate from the JSS inventory information.
BTW, a good way to check your xml for format errors is to use xmllint. There are some other commands as well, but that's the one I use.
xmllint --format /path/to/NoCheckin.xml
If it gives you an error such as:
parser error : Opening and ending tag mismatch: computer_group line 1 and computers
han x days ago</search_type><value>50</value></criterion></criteria></computers>
^
Then there is a problem. Good news is, the ^ actually points to where the problem is in the tags. In this case it indicated that </computers> was the problem tag.
Once I changed the tag as I mentioned above and re-ran xmllint against it, produced:
<?xml version="1.0" encoding="UTF-8"?>
<computer_group>
<name>No check-in</name>
<is_smart>true</is_smart>
<criteria>
<size>1</size>
<criterion>
<name>Last Check-in</name>
<priority>0</priority>
<and_or>and</and_or>
<search_type>more than x days ago</search_type>
<value>50</value>
</criterion>
</criteria>
<computers/>
</computer_group>
which looks much better :)
Hope that helps.
@mm2270 worked for me. Nice practical example of API usage.
@mm2270 Worked like a charm. Thanks - you just saved me a ton of work!
Interesting development: after updating to 9.72, my import no longer works. SAME xml file! I deleted the group and tried to re-add it, using the exact same method as before, and no import. Looking at the API "documentation" (myjss:8443/api) nothing has changed. Strange.
If you're comfortable in ruby at all, just install the jss-api ruby gem (http://pixaranimationstudios.github.io/jss-api-gem/index.html)
then these few lines will do it, no xml needed
#!/usr/bin/ruby
# load in the library
require 'jss-api'
# connect to the JSS
JSS::API.connect :server => 'casper.mysite.org', :user => 'myjssuser', :pw => :prompt, :verify_cert => false
# make a new, uncreated smart computer group
new_smartgroup = JSS::ComputerGroup.new :id => :new, :type => :smart, :name => "no-recent-checkin"
# create a criterion for group membership
criterion = JSS::Criteriable::Criterion.new :and_or => :and, :name => "Last Check-in", :search_type => "more than x days ago", :value => 50
# add the criterion to the group
new_smartgroup.criteria = JSS::Criteriable::Criteria.new [criterion]
# create the group in the JSS
new_smartgroup.create
# the membership is now available in new_smartgroup.members