Blog

Query Users without Photos

If you have user photos in ServiceNow,  here is an useful script to find any users that don't have a photo available:

1. Elevate your privilege to security_admin.
2. In the Left Navigator > Scripts - Background
3. Paste this in the Run Scripts area:

findUserEmptyPhotos();
function findUserEmptyPhotos() {
    var count = 0;
    gs.print("Users Found without Photos:");
    var grUser = new GlideRecord("sys_user");
    grUser.addActiveQuery();Users
    grUser.query();
    //gs.log('grUser Query: ' + grUser.getEncodedQuery() + ' = ' + grUser.getRowCount());
    while (grUser.next()) {
        if (grUser.photo.getDisplayValue() == "") {
            gs.print(grUser.user_name); 
            count++;
        }
    }
    gs.print("Total:"+count);
}

4. Click Run Script