$ mongosh --quiet -u -p --host rs0/ --eval "rs.status().members.map(function(m) { return {'id':m._id, 'name':m.name, 'stateStr':m.stateStr} });" [ { id: 0, name: ':27017', stateStr: 'PRIMARY' }, { id: 1, name: ':27017', stateStr: 'SECONDARY' }, { id: 2, name: ':27017', stateStr: 'SECONDARY' } ] $ mongo --quiet -u -p --host rs0/ --eval "rs.status().members.map(function(m) { return {'id':m._id, 'name':m.name, 'stateStr':m.stateStr} });" [ { "id" : 0, "name" : ":27017", "stateStr" : "PRIMARY" }, { "id" : 1, "name" : ":27017", "stateStr" : "SECONDARY" }, { "id" : 2, "name" : ":27017", "stateStr" : "SECONDARY" } ]