How do I go about importing asset tags when all I have is the serial number that they go to? I have them all setup in a nice spreadsheet. What I’m seeing is some basic answers on what to do but it appears I have to have the computer name?

Also new hardware that’s yet to be deployed: Can I just import at new devices with serial number and asset tag number and then SW will fill out the rest when they’re imaged and deployed?

3 Spice ups

Not sure how many devices you have and it might be a bit of a hassle but you can edit the device name to the asset tag that corresponds with the serial number manually. There’s also an Asset Tag field that you could fill in instead of changing the device name.

several hundred devices

The other issue I guess I’m seeing since I’m still digging looking for answers is I use 3 remote scanners…

Here is what i’m getting for output when I try to run this…mind you I’m only passing “asset_tag” and “serial_number” via the CSV

C:\Program Files\Spiceworks\bin>ruby bulk_import.rb -e myemail@domain.com

-p passwprd -s server-P 8080 --no-manual import.csv

Logging into Spiceworks…

Importing assets…

Error: no name attribute given in {“asset_tag”=>“123123123”, "serial_numb

er"=>“MJ333”, “description”=>“manually imported from csv file”}

Had exception importing: exit

bulk_import.rb:14:in `exit’

bulk_import.rb:14:in `eputs’

bulk_import.rb:139:in `block in

Hi Nic,

You need a “Name” column in your CSV defined to import. It looks like there is an easy work around for you thought. Since the default serial number is the name, if you change the column of the csv from “Serial Number” to “Name”, you should get these devices imported. Later, when a matching device is found with that serial number during a scan, the actual name should be filled in correctly.

Hope that helps,

Francis

2 Spice ups

face palm so the devices now act like they’ve never been scanned before (only did a handful of devices)…I’m kicking off a scan to see if it doesnt’ get them back

okay, so the device scanned and changed the name back to what it should be…however the asset tag field is blank…

I’m trying again but making the column name “Asset Tag” instead of “asset_tag” to see if that resolves that issue.

alright that didn’t work either…so time to go look into the database and see what’s going on there :

before I rescan the device after running the bulk import I see inside the Devices table 39: asset_tag is populated with 123123123 as expected

after I rescan the device that field goes blank…

WHY?!

Hi Nic,

After re-reading your use case and studying our backend code, I’m afraid that this approach isn’t going to work for you. The API the bulk_import script is using mimics our scanner which does try to collect the asset_tag. I’m guessing that the scanner is collecting empty asset_tags and over writing the ones you bulk imported. If you edit these one by one in the UI, a different API is used so that the scanner will not over write manually entered data.

Let me see if I can modify the bulk import script for you so that it just mimics the manually entered path.

Thanks,

Francis

1 Spice up

I see that you’ve got this in there

csv_data.each do |l|

    data={}

    data[:manually_added] = true if options.manual

Would it be possible to make ‘asset_tag’ a manual entry regardless of the “–no-manual” flag being on?

Hi Nic,

I wrote you another script to update the asset_tag attribute properly. I will email it to you with instructions. If the asset doesn’t exist yet in our inventory, you need to run this current bulk import script to get them in the system, or manually add them one by one from our user interface first.

Thanks,

Francis

2 Spice ups

Francis thank you so much!! Worked like a charm.

Hi Francis,

Is it possible you can send me the script as well.

Thanks

Will do Adam.

Thanks Francis, all working now

Can you send it to me as well, please?

Check your email Alyssa. I just sent you the script.

Got it, thanks!

Francis,

May I also have a copy of the script?

Thank you!