> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ユーザーのプロビジョニング解除とフォルダのアーカイブ

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

このスクリプトを使用すると、ユーザーのリストによるプロビジョニング解除と削除が可能です。スクリプトでは以下の手順が実行されます。

1. `EmployeeArchiveFolderName`パラメータで指定された、別のユーザーのルートフォルダにユーザーコンテンツを転送します。
2. ユーザーを削除します。

## 前提条件

### Windows

[.NET Core](https://dotnet.microsoft.com/download)の最新バージョンのインストール

### macOSおよびLinux

[PowerShell][pwsh]をインストールします。`pwsh`コマンドを実行して、インストール結果をテストします。

```bash theme={null}
pwsh
```

どのディレクトリでこのコマンドを実行するかに応じて、出力が異なる場合があります。以下に例を示します。

```bash theme={null}
PowerShell 7.2.5
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /Users/user/repos/boxcli/examples>
```

<message>
  問題が発生する場合は、[.NET Core](https://dotnet.microsoft.com/download)と[PowerShell][pwsh]の両方をインストールしたかどうか確認してください。
</message>

### Box CLI

スクリプトを使用するには、Box CLIをインストールし、構成する必要があります。これを実行するには、<Link href="/guides/cli">クイックスタートガイド</Link>の手順に従います。ログインに使用するユーザーは、Boxのメイン管理者または共同管理者である必要があります。

## スクリプトの構成

1. `boxcli` GitHubリポジトリを複製してこの例のフォルダにcdコマンドで移動するか、[`examples`][examples]ディレクトリからファイルをダウンロードします。

   ```bash theme={null}
   git clone https://github.com/box/boxcli.git boxcli
   cd boxcli/examples/User\ Deprovisioning/
   ```

2. 削除する従業員のリストを`.csv`で作成します。

   ヘッダー行は次のようになります。

   ```bash theme={null}
   name, email
   ```

   この場合

   * `name`は、Boxにおけるユーザーの名前です。
   * `email`は、Boxにおけるこのユーザーのプライマリメールアドレスです。

   例:

   | `name`    | `email`                 |
   | --------- | ----------------------- |
   | 管理対象ユーザー1 | `ManagedUser1@test.com` |
   | 管理対象ユーザー2 | `ManagedUser2@test.com` |
   | 管理対象ユーザー3 | `ManagedUser3@test.com` |

### パラメータのリスト

| `Parameter`                 | `Description`                                                                                                                                                | `Required` | `Default Value`                                       |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------- | ----------------------------------------------------- |
| `EmployeeList`              | 削除する従業員が記載された従業員リストCSVのパス。                                                                                                                                   | はい         | -                                                     |
| `SkipTransferContent`       | このフラグを設定すると、スクリプトの実行時に、削除前にユーザーコンテンツの転送をスキップします。設定しない場合は、ユーザーのコンテンツが転送されます。                                                                                  | いいえ        | `False`                                               |
| `NewFilesOwnerID`           | ユーザーの削除前にファイルの転送先となるユーザーのID。指定しなかった場合、スクリプトは、対話形式で入力を求めるか、現在認証されているユーザーのIDを使用してコンテンツを受け取ります。                                                                 | いいえ        | 指定しなかった場合、スクリプトは、対話形式で入力を求めるか、現在認証されているユーザーのIDを使用します。 |
| `EmployeeArchiveFolderName` | `SkipTransferContent`が`False`に設定されている場合にユーザーのコンテンツの移動先となるフォルダの名前。この名前のフォルダがそのユーザーの`NewFilesOwnerID`ルートフォルダにすでに存在する場合は、そのフォルダが使用されます。存在しない場合は、新しいフォルダが作成されます。 | はい         | `Employee Archive`                                    |
| `DryRun`                    | 削除/作成/更新の呼び出しは行われず、読み取りの呼び出しのみが行われるモードでスクリプトを実行するかどうかを決定するフラグ。                                                                                               | いいえ        | `False`                                               |

### スクリプトのパラメータの定義

パラメータを渡すには、以下のオプションを使用できます。

* スクリプトでハードコードされた値を使用します。

  このオプションを使用するには、実行する前に、[スクリプトのパラメータセクション][parameters]に記載されている必須パラメータをすべて更新します。

* パラメータを指定してスクリプトを実行します。

  コマンドを指定するときにパラメータを指定できます。以下に例を示します。

  ```bash theme={null}
  PS > ./Users_Deprovision.ps1 -EmployeeList ./Employees_to_delete.csv `
  -NewFilesOwnerID  123456789
  -EmployeeArchiveFolderName "Employee Archive"
  ```

  または

  ```bash theme={null}
  PS > ./Users_Deprovision.ps1 -EmployeeList ./Employees_to_delete.csv `
  -SkipTransferContent
  ```

  パラメータを指定しなかった場合は、スクリプトによって、パラメータを入力するよう求められます。

  ```bash theme={null}
  PS > ./Users_Deprovision.ps1
  Please enter the path to the employee list CSV file:
  ./Employees_to_delete.csv
  Please specify the user ID of the user who will own the files of the users being deprovisioned.
  Press Enter if you want to use the current user as the new owner.
  User ID: 1234567689
  Starting User Deprovisioning script...
  ```

## スクリプトの実行

これで、あとはスクリプトを実行するだけです。

1. PowerShellコマンドを実行します。

   ```bash theme={null}
   pwsh
   ```

2. スクリプトを実行します:

   ```bash theme={null}
   ./Users_Deprovision.ps1
   ```

   すべてのパラメータが定義されると、以下の出力が表示され、スクリプトが開始されたことを確認できます。

   ```bash theme={null}
   PS /home/rvb/box-cli/examples/User Deprovisioning> ./Users_Deprovision.ps1
   Starting User Deprovisioning script...
   ```

## ログ

ログは、メインフォルダ内の`logs`フォルダに格納されます。以下のログファイルにアクセスできます。

* `Users_Deprovision_all.txt`: すべてのログエントリが含まれています。
* `Users_Deprovision_errors.txt`: エラーのみが含まれています。

[scripts]: https://github.com/box/boxcli/tree/main/examples

[pwsh]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.2

[console]: https://app.box.com/developers/console

[auth]: /guides/authentication/oauth2/oauth2-setup

[examples]: https://github.com/box/boxcli/tree/main/examples/User%20Deprovisioning

[parameters]: https://github.com/box/boxcli/tree/main/examples/User%20Deprovisioning/Users_Deprovision.ps1#L17-L36

[employeelist]: https://github.com/box/boxcli/blob/main/examples/User%20Deprovisioning/Users_Deprovision.ps1#L12

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("OAuth 2.0 Auth"), href: "/guides/authentication/oauth2/index", badge: "GUIDE" },
{ label: translate("Using PowerShell Scripts with the Box CLI"), href: "/guides/cli/scripts/powershell-script-templates", badge: "GUIDE" }
]}
/>
