> ## 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.

# Report inactive users

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 = href;
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

This script generates a CSV file with a list of users who have been inactive for a number of days. It performs the following steps:

1. Looks for the users who have the role `user`.

   <Info>
     The script does not consider other roles, such as `AppUser`.
   </Info>

2. Uses <Link href="/reference/resources/event">Box Events</Link> to check if the user performed any actions for a specified number of days. The default list of event types includes: `LOGIN`,`UPLOAD`,`COPY`,`MOVE`,`PREVIEW`,`DOWNLOAD`,`EDIT`,`DELETE`,`UNDELETE`,`LOCK`,`UNLOCK`, `NEW_USER`. You can modify this list in the script settings.

3. Adds users who didn't perform any actions to a `.csv` file with inactive users. You can use this file as input for other scripts, for example to <Link href="/guides/cli/scripts/deprovision-users">deprovision users</Link>.

## Prerequisites

### Windows

Install the latest version of [.NET core](https://dotnet.microsoft.com/download).

### macOS & Linux

Install [PowerShell][pwsh]. Run the `pwsh` command to test the installation.

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

Depending on the directory you are
running the command in, the output may differ.
For example:

```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>
  If you encounter issues make sure you installed both
  [.NET core](https://dotnet.microsoft.com/download) and
  [PowerShell][pwsh].
</message>

### Box CLI

To use the script, you need the Box CLI
installed and configured. You can do this by following
our <Link href="/guides/cli">quick start guide</Link>. The user you use to login with should
be the main Box admin or co-admin.

## Configure the script

1. Clone the `boxcli` GitHub repository and cd into this example's folder or download the files from the [`examples`][examples] directory.

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

2. Set the number of days you want the script to scan for user events. If you   don't specify this value or leave the default, the script will prompt you to enter it.

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

3. (Optional) To change the report output file name, define the `ReportOutputFile` parameter.

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

4. (Optional) To change event types, define the list for `eventType` parameter.

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

## Run the script

Run the Powershell command.

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

Run the script.

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

When the script run is completed, you will see the following
output or a similar one.

```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
```

## Logging

Logs are stored in the `logs` folder located in the main folder.
You have access to these log files:

* `Inactive_Users_Report_all.txt` - contains all log entries
* `Inactive_Users_Report_errors.txt` - contains only errors.

[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="RELATED GUIDES"
  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" }
]}
/>
