> ## 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>;
};

このスクリプトは、一定の日数の間非アクティブであったユーザーのリストをCSVファイルで生成します。スクリプトによって以下の手順が実行されます。

1. `user`ロールを持つユーザーを探します。

   <Info>
     このスクリプトでは、他のロール (`AppUser`など) は考慮していません。
   </Info>

2. <Link href="/reference/resources/event">Box Events</Link>を使用して、そのユーザーが一定の日数の間に操作を行ったかどうかを確認します。デフォルトのイベントタイプのリストは、`LOGIN`、`UPLOAD`、`COPY`、`MOVE`、`PREVIEW`、`DOWNLOAD`、`EDIT`、`DELETE`、`UNDELETE`、`LOCK`、`UNLOCK`、`NEW_USER`です。このリストはスクリプトの設定で変更できます。

3. 操作を行わなかったユーザーを、非アクティブなユーザーが含まれている`.csv`ファイルに追加します。このファイルは他のスクリプト (<Link href="/guides/cli/scripts/deprovision-users">ユーザーのプロビジョニング解除</Link>など) の入力として使用できます。

## 前提条件

### 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
   cd boxcli/examples/Inactive\ Users\ Report/
   ```

2. スクリプトでUser Eventをスキャンする日数を設定します。この値を指定しなかった場合やデフォルト設定のままにした場合は、スクリプトによって入力するよう求められます。

   ```bash theme={null}
   $daysInactive = "10"
   ```

3. (省略可) レポート出力ファイル名を変更するには、`ReportOutputFile`パラメータを定義します。

   ```bash theme={null}
   $ReportOutputFile = $ReportName + ".csv"
   ```

4. (省略可) イベントタイプを変更するには、`eventType`パラメータのリストを定義します。

   ```bash theme={null}
   $eventType = "LOGIN,UPLOAD,COPY,MOVE"
   ```

## スクリプトの実行

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

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

スクリプトを実行します。

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

スクリプトの実行が完了すると、以下のような出力が表示されます。

```bash theme={null}
Looking for users inactive for more than 3 days.
Found 6 users.
Found 7 events in last 3 days
Enterprise has: 0 App user, 6 regular users. With 1 admin role, 5 user roles.
Need to check 5 users (regular user, with user role) for inactive.
Found 5 users inactive for more than 3 days.
Report is available at InactiveUsers.csv
```

## ログ

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

* `Inactive_Users_Report_all.txt` - すべてのログエントリが含まれています。
* `Inactive_Users_Report_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/Inactive%20Users%20Report

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("OAuth 2.0 Auth"), href: "/guides/authentication/oauth2/index", badge: "GUIDE" },
{ label: translate("PowerShell script templates"), href: "/guides/cli/scripts/powershell-script-templates", badge: "GUIDE" },
{ label: translate("Deprovision users and archive folders"), href: "/guides/cli/scripts/deprovision-users", badge: "GUIDE" },
{ label: translate("Update user zones"), href: "/guides/cli/scripts/user-zones-mass-update", badge: "GUIDE" }
]}
/>
