mm2270 / JamfProScripts

A collection of shell scripts created for use in Jamf Pro and elsewhere
MIT License
172 stars 30 forks source link

create_ARD_computer_list.sh error #8

Open SGNTP opened 8 years ago

SGNTP commented 8 years ago

Hi Mike,

Thanks for all the hard work you do - you probably hear it often but we mean it! When you have time could you check out this consistent error I get when using this script:

Running Mac OS X 10.10.5 (14F1807)
Verifying /usr/local/jamf/bin/jamf...
/usr/local/jamf/bin/jamf is current (9.82)
Verifying /usr/sbin/jamf...
/usr/sbin/jamf does not exist.
Verifying /Library/Preferences/com.jamfsoftware.jamf.plist...
Preparing Policy...
Executing Policy 2016-05-10 at 4:10 PM | myusername | 1 Computer
Running script Create ARD list...
Script exit code: 0
Script result: 4878:4884: syntax error: A identifier can’t go after this “"”. (-2740)
-:1: parser error : Document is empty
-:1: parser error : Document is empty
-:1: parser error : Document is empty
ARD group plist named ".plist" was created successfully and moved to your Desktop
Submitting log to https://myjjurl:8443/
Finished.

The resulting plist looks like so:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>items</key>
    <array>
        <dict>
            <key>hardwareAddress</key>
            <string></string>
            <key>name</key>
            <string></string>
            <key>networkAddress</key>
            <string></string>
            <key>networkPort</key>
            <integer>3283</integer>
            <key>vncPort</key>
            <integer>5900</integer>
        </dict>
    </array>
    <key>listName</key>
    <string></string>
    <key>uuid</key>
    <string>D0680978-16BF-11E6-AD61-ACBC32883C51</string>
</dict>
</plist>

I get the same output when running it from the Terminal. Whats baffling me is the syntax error which I gather isn't happening on other JSS and OS version for other people.

mm2270 commented 8 years ago

Hi @SGNTP, Sorry for the delayed response on this.

I see two issues going on here, but really its the first one that is likely the problem. I see from your script output that it looks like you tried to run the script through Casper Remote, If so, this script isn't designed to be run from any kind of Casper policy, because it pops up an Applescript window asking for the Computer Group selection to be converted to an ARD list. The error syntax error: A identifier can’t go after this “"” is coming from Applescript and is because it can't execute the osascript call to send up the dialog. Try running the script manually in Terminal and you'll see what I mean.

The parser error : Document is empty errors later on are coming from xmllint, which takes incoming xml and formats it in a way that makes it easier to get specific lines in the xml. The issue is that since its not getting an xml from the curl command before it, it generates that parser error. But again, this is all because of how you're trying to run the script it seems.

mm2270 commented 8 years ago

Commenting again, I see you mentioned getting the same error from Terminal. If so, what I'd check is the API account permissions. Make sure it has READ access to Computer Groups (Smart and Static) and Computers. It needs all of those at a minimum to work.

ddddbeck commented 7 years ago

Hi Mike,

Very thankful for all the work you do that helps me to do better and learn new things!

Environment: Cloud-hosted JAMF

Is it possible to edit the script and get the "Reported IP Address" from the API?

When I run search in API (Computer/ID), this is what returns:

<ip_address>63.xxx.xxx.xxx</ip_address>
<last_reported_ip>10.xxx.xxx.x</last_reported_ip>

Editing the script to use last_reported_ip or LAST_REPORTED_IP did not return any information.