# Granting the migrator role

The migrator role gives a user or team the ability to run migrations on behalf of an organization.

To allow someone other than an organization owner to run a migration or download migration logs, you can grant the migrator role to a user or team.

To grant the migrator role using the CLI, you can use the ADO2GH extension of the GitHub CLI.

1. 安装 GitHub CLI。
   * 有关 GitHub CLI 的安装说明，请参阅 [GitHub CLI 存储库](https://github.com/cli/cli#installation)。
   * 如果已安装 GitHub CLI ，请运行 `gh --version` 以确保运行版本 2.4.0 或更高版本。 如果有较旧版本，请访问 [GitHub CLI 存储库](https://github.com/cli/cli#installation) 以获取升级说明。
1. 安装 ADO2GH extension。

   ```shell copy
   gh extension install github/gh-ado2gh
   ```

1. ADO2GH extension of the GitHub CLI 每周更新一次。 为了确保使用的是最新版本，请更新扩展。

    ```shell copy
    gh extension upgrade github/gh-ado2gh
    ```

1. On GitHub, create and record a personal access token that has the `admin:org` scope.
1. 将 personal access token 设置为环境变量，将以下命令中的 TOKEN 替换为你在上面记录的 personal access token。

   * 如果使用终端，请使用 `export` 命令。

      ```shell copy
      export GH_PAT="TOKEN"
      ```

   * 如果使用 PowerShell，请使用 `$env` 命令。

      ```shell copy
      $env:GH_PAT="TOKEN"
      ```
1. Use the `gh ado2gh grant-migrator-role` command, replacing ORGANIZATION with the organization you want to grant the migrator role for, ACTOR with the user or team name, and TYPE with `USER` or `TEAM`.

   ```shell copy
   gh ado2gh grant-migrator-role --github-org ORGANIZATION --actor ACTOR --actor-type TYPE
   ```

   >[!NOTE] 如果要为其授予迁移程序角色 GHE.com，还必须包含企业子域的目标 API URL。 例如：`--target-api-url https://api.octocorp.ghe.com`。