...
- Go to ServiceNow, ideally not PROD instance, and login as admin user.
- Navigate to application filter (top left corner), type in sys_user.list to dump the user table.
- This will find potentially 200k or so entries, and you cannot export that many accounts.
- Define a filter, which shows you a subset of users. Here's a way: "NetID starts with b"
- Apply that filter, which limited me down to 7715 hits
- Right click on the results page, along the column headers.
- You will get a new menu, with an Export submenu
- Pick CSV out of that list
- Choose to download the export
How to
...
rebuild a user_sys locally
I had a collection of .csv files with fewer than 50k entries, but it's nicer to work with the full set when performing queries.
Code Block |
---|
zuse:Downloads db692$ head sys_user_from_testcat users_starts_numeric.csv users_starts_with_a-c.csv users_starts_with_bd-i.csv "user_name","employee_number","name","title","source","u_facit","u_organization.u_department.u_division.u_id","u_organization.u_department.id","u_organization.u_id","active","mobile_phone","sys_created_on" "b1912a","10793883","Brian Marshall","","","false","","","","false","","2012-02-23 11:43:23" "ba2","10089420","Beatrice Abetti","","","false","D00609","G00806","872108","false","","2012-02-23 09:23:43" "ba22","10097002","Barbara Amato-Kuslan","","","false","D03474","G01951","960003","true","","2012-02-23 09:24:22" |
You want to look for the subset with colliding netids...
Code Block |
---|
zuse:Downloads db692$ cat sys_user_from_test_starts_with_b.csv | awk -F, '{print $1}' | uniq -d | wc 34 34 users_starts_with_j-l.csv users_starts_with_m-r.csv users_starts_with_s-z.csv > all_users.csv # catch the header lines, and delete all but the first one grep -n user_name all_users.csv sed "175824d;127985d;81587d;41395d;125d" all_users.csv > all_users_one_header.csv cut -d, -f1 all_users_one_header.csv > all_users_just_usernames.csv |
How to parse the export csv with a subset of the user table...
Code Block |
---|
zuse:Downloads db692$ head sys_user_from_test_starts_with_b.csv
"user_name","employee_number","name","title","source","u_facit","u_organization.u_department.u_division.u_id","u_organization.u_department.id","u_organization.u_id","active","mobile_phone","sys_created_on"
"b1912a","10793883","Brian Marshall","","","false","","","","false","","2012-02-23 11:43:23"
"ba2","10089420","Beatrice Abetti","","","false","D00609","G00806","872108","false","","2012-02-23 09:23:43"
"ba22","10097002","Barbara Amato-Kuslan","","","false","D03474","G01951","960003","true","","2012-02-23 09:24:22"
|
You want to look for the subset with colliding netids...
Code Block |
---|
zuse:Downloads db692$ cat sys_user_from_test_starts_with_b.csv | awk -F, '{print $1}' | uniq -d | wc
34 34 271
|
My concerns about this approach
...
I've also approached the problem of finding the bad account entries in Service Now that have not YET collided with a legitimate account, but will in the future as new NetIDs are created. Said differently, these are the difference between the overall set of users in Service Now and the set of users in Central Auth. I've been using a collection of MySQL and command line tricks to tease out these entries, and I think my fifth round results are both accurate and my data analysis approach will get a result in a reasonable amount of time. Then we will probably put those results through the same scrutiny as my original set of duplicates data set.
The correct Service Now script to wipe bad user entries
Code Block |
---|
/** * For variables go to: http://wiki.service-now.com/index.php?title=Import_Sets **/ var netid = source.netid; var rec = new GlideRecord('sys_user'); /*rec.addQuery('user_name','=',source.u_netid);*/ rec.addQuery('user_name',source.u_netid); rec.addQuery('sys_created_on','<','2012-02-24 12:00:00'); rec.addInactiveQuery(); rec.query(); if (rec.next()){ rec.deleteRecord(); } |