Clear username from computer record

cbrewer
Valued Contributor II

We have usernames populated using "jamf recon -endUsername $user" on many machines.

Is there a way to use the -endUsername option to clear the username record?

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

That script looked very familiar. It took a couple of searches to locate it, but looks like it came from this thread: https://jamfnation.jamfsoftware.com/discussion.html?id=10449

Just a quick note: There's a slightly modified version on the same thread posted by the OP that uses the Mac's serial number instead of a MAC address. I've made it habit myself to start using the Serial number lately with many of my API scripts.

View solution in original post

3 REPLIES 3

Rayfield
New Contributor III

This is the script we use. Pretty sure I got it off of here in the past, just make sure you fill in the apiUser, apiPass, and jssURL fields.

If I find exactly where I got it I'll give credit :D

We have this run on any computer that has the wrong name (IT Support account) and also automatically on newly imaged computers before they are assigned to users.

#!/bin/sh

## Change these 3 variables to match your setup. API account must have API write privs
apiUser=" ***** "
apiPass=" ***** "
jssURL=" ***** "

## get this Mac's MAC address
MAC=$( networksetup -getmacaddress en0 | awk '{print $3}' | sed 's/:/./g' )

## Create the xml for upload via API
echo "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<computer>
    <location>
        <username/>
        <real_name/>
        <email_address/>
        <position/>
        <phone/>
        <department/>
        <building/>
        <room/>
    </location>
</computer>" > "/tmp/blank_location.xml"

## Now upload the xml file
curl -s -k -u "${apiUser}:${apiPass}" "${jssURL}/JSSResource/computers/macaddress/$MAC" -T /tmp/blank_location.xml -X PUT

mm2270
Legendary Contributor III

That script looked very familiar. It took a couple of searches to locate it, but looks like it came from this thread: https://jamfnation.jamfsoftware.com/discussion.html?id=10449

Just a quick note: There's a slightly modified version on the same thread posted by the OP that uses the Mac's serial number instead of a MAC address. I've made it habit myself to start using the Serial number lately with many of my API scripts.

cbrewer
Valued Contributor II

Thanks to both of you. I do like the idea of using the serial number as we've gotten away from using MAC addresses wherever possible.