title: Changing GCP IAM roles for multiple users
body: <p>I have over one hundred GCP users that have mixed roles. These users were manually created via IAM console by different admin personnel.  We would like do some clean up to the project.  The roles needed for these users are simply project viewer, bigquery user, bigquery data viewer and bigquery jobuser. I would like to change the roles of these 100+ users with a single command. Is there a way to do this?</p>
  <p>Below is an example of IAM list that I retrieved from GCP command</p>
  <blockquote>
  </blockquote>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>gcloud projects get-iam-policy example-project-id-1</code></pre>
  </div>
  </div>
  </p>
  <p>This is simply a dummy data and a modified version for security reasons.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>---
  policy:
    bindings:
    - members:
      - user:Sanaa.Keller@abc.com
      - user:adam.skill@abc.com
      - user:albert.withmore@abc.com
      - user:alison.mcknight@abc.com
      - user:andre.soretti@abc.com
      - user:andrew.born@abc.com
      - user:andrew.hill@abc.com
      - user:andrew.ives@abc.com
      - user:andrew.windridge@abc.com
      - user:angela.hammond@abc.com
      - user:anil.patel@abc.com
      - user:anna.lynch@abc.com
      - user:ben.carlson@abc.com
      - user:elisabeth.morrison@abc.com
  
      role: roles/editor
  project: projects/926557397521
  resource: //cloudresourcemanager.googleapis.com/projects/abc-staging
  ---
  policy:
    bindings:
    - members:
      - user:Sanaa.Keller@abc.com
      - user:adam.skill@abc.com
      - user:albert.withmore@abc.com
      - user:alison.mcknight@abc.com
      - user:andre.soretti@abc.com
      - user:andrew.born@abc.com
      - user:andrew.hill@abc.com
      - user:andrew.ives@abc.com
      - user:andrew.windridge@abc.com
      - user:angela.hammond@abc.com
      - user:anil.patel@abc.com
      - user:anna.lynch@abc.com
      - user:ben.carlson@abc.com
      - user:elisabeth.morrison@abc.com
  
      roles:roles/bigquery.dataEditor
  project: projects/926557397521
  resource: //cloudresourcemanager.googleapis.com/projects/abc-staging
  ---
  policy:
    bindings:
    - members:
      - user:Sanaa.Keller@abc.com
      - user:adam.skill@abc.com
      - user:albert.withmore@abc.com
      - user:alison.mcknight@abc.com
      - user:andre.soretti@abc.com
      - user:andrew.born@abc.com
      - user:andrew.hill@abc.com
      - user:andrew.ives@abc.com
      - user:andrew.windridge@abc.com
      - user:angela.hammond@abc.com
      - user:anil.patel@abc.com
      - user:anna.lynch@abc.com
      - user:ben.carlson@abc.com
      - user:elisabeth.morrison@abc.com
  
      roles:roles/bigquery.jobUser
  project: projects/926557397521
  resource: //cloudresourcemanager.googleapis.com/projects/abc-staging
  ---
  policy:
    bindings:
    - members:
      - user:brian.king@abc.com
      role: roles/editor
  project: projects/926557397521
  resource: //iam.googleapis.com/projects/abc-staging/serviceAccounts/qlikview@abc-staging.iam.gserviceaccount.com</code></pre>
  </div>
  </div>
  </p>
  <p>So, what i would like to do from the above example is to remove the the project editor role and simply assign them roles of BigQuery Data Viewer and BigQuery Job User</p>